tags:

views:

94

answers:

2

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..

A: 

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.

RarrRarrRarr
I disagree with this being down-voted... given the information present, I think that's about the best answer one could give. =P
Chris Cooper
Being the "best answer one can give" doesn't necessarily make it a particularly good answer, though. Personally, I wouldn't downvote it, but I wouldn't be inclined to upvote it either.
Brooks Moses
+1  A: 

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.

RWS