Can a Large Matrix Allocation Cause a Windows Error in Circuit Simulation?

AI Thread Summary
Allocating large matrices in C++ for circuit simulations can lead to Windows errors, particularly when exceeding certain limits, such as 32768 or 65536, which may not be an issue on Unix systems. The user experienced crashes when increasing the matrix size beyond 28000, suggesting a potential memory allocation limit or segmentation fault. Switching to "unsigned long int" for the steps variable may help by allowing for a larger range of positive integers. The user also reduced the matrix to three single arrays but still encountered issues, indicating possible memory overlap or access violations. Further troubleshooting and adjustments to memory management are recommended to resolve the segmentation fault.
Phymath
Messages
183
Reaction score
0
Hey,

In doing a circuit simulation i want to allocate a matrix like this (c++)

double S1store[3][steps+1]

i get no compiling errors, but if i make steps greater then 28000 the program gives me a windows error and crashes, it runs fine on a unix system. is there a limit to the amount of data you can allocate at one time? (i have 1GB RAM 3.2 Ghz processor) i don't think that would fill up. Or do you think the compiler doesn't complie correctly when your matrix is that large?

thanks for any help, i would have put this is programming but i know there's better programmers in physics lol
 
Physics news on Phys.org
There is a limit, it should be either 32768 or 65536 , not 28000. But I'll assume you went from 28000 to 35000 or something, and that's when it crashed. Try changing the steps to be of type "unsigned long int" instead of type "int" that should give you some more room. Unsigned tells the computer not to allow the int to store negative numbers, doubling the number of positive numbers it can hold. Long int tells it to allocate more bits to storage increasing the number of ints it can hold (but sometimes exactly how much it increases depends on the compiler / operating system, which is probably why this is working on *nix and not windows)

~Lyuokdea
 
ya thanks a lot its a segmentation fault good idea about the unsigned i already have the long int, i also reduced the matrix to three single arrays

SnstoX[steps], SnstoY[steps],SnstoZ[steps], now I am maxing out at around 149896 = steps. I'm thinking that the program is trying to "point" to memory spots already taken up in the program, as in SnstoX[1] could have the same mem spot as SnstoX[120000] and the computer is obviously segfaulting...im 99.5% positive I am not accessing memory not allocated in the arrays...as in I am not accessing SnstoX[steps] literally but SnstoX[steps-1] which is suposed to be the max, ill try the unsigned thing thanks if you got any more ideas that'd be helpful
 
Thread 'Collision of a bullet on a rod-string system: query'
In this question, I have a question. I am NOT trying to solve it, but it is just a conceptual question. Consider the point on the rod, which connects the string and the rod. My question: just before and after the collision, is ANGULAR momentum CONSERVED about this point? Lets call the point which connects the string and rod as P. Why am I asking this? : it is clear from the scenario that the point of concern, which connects the string and the rod, moves in a circular path due to the string...
Back
Top