开发者

dynamic memory allocation problem

I am working on a program that requires me to make use of 4 matrices sized [1000][1000]. I have created them using malloc(), but when I try running the program 开发者_开发问答it just crashes and the memory usage shoots up to 2.5 GB. Please suggest any solution as soon as possible. I would be grateful..


4 matrices sized [1000][1000]

Why use malloc() when you know at compile time how much memory you need? Dynamically allocating two-dimentional arrays is not the most trivial thing to do, neither is freeing them (see the C FAQ, Question 2.14 on one way to do this). Do not over-complicate your programs.


Why don't you run the program inside a debugger, such as gdb, to see exactly where it crashes? It will help you narrow down the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜