Web Development

General discussion


program memory limits

By solrak29 ·
I'm programming on Unix based systesm and watched my process grow to about 2gig through the top utility and it crashed. I then set the ulimit to unlimited for memory and now when my program hits the 2gig magic number I get unpredictable results from my application.

I thought that a program has 4gig of memory access and can any explain the phenomena and/or point me to any documentation on any discussion on this issue.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by Jaqui In reply to program memory limits

combine your physical ram with your swap partition size, that is your memoryy cap.
then reduce to what is available as system uses part.

the goal is to use the least amount of resources for any one application.
target your app to run with only using 10kb of ram. that is the goal of any decent programmer
( not possible but a good target )

Collapse -

by solrak29 In reply to

Poster rated this answer.

My physical ram and swap partition size are both in the gig range, huge. And this is why I post the question...my application get unpredictable results at 2gig and other test applications will not let me allocate memory larger than 2gig (limitation of an signed int). I just figured as your reply says that the application should be able to use all the unavailable memory. The other interesting note is in the architecture of a process, where a stack and a heap can collide. Why would they grow towards eachh other? Why not have the heap grow up instead of down? But lets stick whith my first question first. Thanks for your reply.

Collapse -

by DSR28 In reply to program memory limits

Try to allocate in smaller chunks. At some point, you will allocate a size that cannot fit consecutively in memory in one block - and when this happens, the allocate will fail.

If you have 2 GB ram and 2 GB swap, you cannot expect that a 2GB alloc and another 2GB alloc will succeed. Perhaps even 3 x 1 GB allocs would fail, depending on the system and how it handles memory management. (If you are doing this in C, C++, remember you are dealing with the C libraries, generally and not the Memory manager itself)

Also - ensure that the c libraries you use are capable of handling large allocations. Some libraries have problems with pointer arithmetic at large allocation sizes as they navigate their structures of allocations.

And finally with regards to memory allocations, check to see if your c standard libraries creat a second heap, or if it is possible to create a heap and work it yourself with the system memory management calls rather than the c library itself.

The app shouldn't have crashed unless the code is not checking the return on an allocate or something like that. (the C libraries may do this too - they are not totally impervious to that sort of thing!)

Collapse -

by solrak29 In reply to

Ahhh, I like your answer and it makes total sence. I will give it a shot with a sample application and investigate memory allocation routines as you suggested above.

Collapse -

by solrak29 In reply to program memory limits

This question was closed by the author

Related Discussions

Related Forums