+ 7
Segmentation fault (Core dumped)
I have a problem in C. My program generally works good but when I try to make an array with more than 10.000 elements it throw this error. What to do?
13 Réponses
+ 12
Lighton if you are getting a segmentation fault then it means that you are trying to access a memory location that is not accessible.
Edit: 10000*5000 = 50000000 elements and each occupy 4 bytes of memory so the memory occupied is 200000000 bytes. Do you understand how big is that?
+ 5
Can you show us the code?
+ 5
Ruchika Tripathi your post is irrelevant!
+ 3
HonFu To be honest I do not know the answer to that but a 200 mb file sounds very big. In general our files are hardly few kilo bytes.
I do not exactly know that what part of RAM is allocated for a particular program but I hope to find the answer to that.
+ 3
Kit D. Cat how does one check for the stack memory on their system? Also thank you for making things clear.
+ 2
Avinesh, is there some way to know how large these arrays can be?
I mean, sure, what is it, 200 mb, is large, but shouldn't a regular pc be able to do it anyway?
naive Pythonist -->
+ 2
Okay, 8mb is not a lot... So if OP reconfigured the code to using heap space, huge arrays like that would become possible?
+ 1
Yes, wait a moment
+ 1
It's a part of my school excercise.
Line 35 is accidentally there so it was not the problem.
Can you run it with 10000*5000 elements
+ 1
Oh yes, so the problem is in the size of this array. There is no any syntax mistakes, right?
0
Remove line 35 and then input 2 array size values. It outputs m×n matrix.
But do not understand what you are trying to achieve.
0
Le problème est dans l'espace mémoire je pense.