-
August 31st, 2010, 12:46 PM
#1
My program is hungry for memory
I have to allocate memory for my variables
I have to use malloc
it works
Only that I wonder what if I no longer have more memory to offer ? what happen during the request being proess?
Thank you
-
August 31st, 2010, 12:51 PM
#2
Re: My program is hungry for memory
If you run out of physical RAM, most OSes will begin swapping out portions of the address space to disk. This is fine if the swapped out portions of memory won't be needed for a while; but if you are frequently accessing all parts of memory, then you can get excessive swapping, called thrashing, which could slow down your program by 100x or more.
If you run out of address space----which usually happens between 1.5 and 2GB of allocation in a 32-bit process, regardless of how much physical RAM you have----then malloc() will simply fail and return NULL. If you're using new instead of malloc, then it may throw an exception instead.
The majority of programs do not require so much memory that this is a problem. Usually, running out of memory means that you aren't managing it correctly.
-
August 31st, 2010, 12:54 PM
#3
Re: My program is hungry for memory
You may want to read McKusick's paper for Linux memory management
-
August 31st, 2010, 01:15 PM
#4
Re: My program is hungry for memory
Thanks, Lindley for details
@TheComputer, thanks I find a lot of McKusick on google search
-
August 31st, 2010, 01:19 PM
#5
Re: My program is hungry for memory
@TheComputer, but sad McKusick only states little information about what I am doing, not really correct about what I am doing
-
August 31st, 2010, 01:29 PM
#6
Re: My program is hungry for memory
If this is a real situation, you may want to rethink your program design.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|