int **Point_in_Range;
sub_vol_size_xi =512;
sub_vol_size_yi =512;
sub_vol_size_zi=512;
Point_in_Range=(int**)malloc(sizeof(int*)*(sub_vol_size_xi*sub_vol_size_yi*sub_vol_size_zi));
cout<<"Get Here1"<<endl;
for(j=0;j<sub_vol_size_xi*sub_vol_size_yi*sub_vol_size_zi;j++){
cout<<j<<endl;
Point_in_Range[j]=(int*)malloc(sizeof(int)*3);
}

What is the memory problem.... been stuck on this for a little while now.

thanks in advance

Recommended Answers

All 6 Replies

512 * 512 * 512 * 4 = 536,870,912, or about 524 meg. Does your computer have that much RAM?

Check the return value of malloc() -- it will return NULL is not enough memory to allocate.

Good point. I do have 2 gigs but I have much other allocated stuff... I will check if im full.

That's 524 meg only for the allocation of the first array. Then your program allocates 134,217,728 more arrays of 3 integers each, or another 1,610,612,736 bytes, for total of 2,147,483,648 (2,097,152 meg). Your computer does not have that much free ram.

I see . Good point. Unfortunately, I need to come up with a new method of region growing with better memory managment. Maybe lists?

depends on what you want them for. do you need integers? or will just one bit do each element?

> I need to come up with a new method of region growing with better memory managment. Maybe lists?
It would have to be a pretty sparse array to make this work well.
You can't index a list the same way you can an array, so any more than a few 100's of entries will really start to burn CPU time.

How dependent are array elements to their neighbours? Do you really need to store the whole array at once?

For example, could you get by with 128*128*128 (~100MB in total), then re-use that 64 times to process the 512*512*512 sized block?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.