Archived

This topic is now archived and is closed to further replies.

Metal Typhoon

free store (heap) question

Recommended Posts

Metal Typhoon    122
when we use new to create variables they r from the heap, a where memory was set aside for dynamic variables.. how much of this FREE STORE is avaliable out of the whole memory ? like let''s say 256 ram .. how much % is heap ? and when it runs out of heap what happens ?
Metal Typhoon

Share this post


Link to post
Share on other sites
Oluseyi    2116
quote:
Original post by Metal Typhoon
how much of this FREE STORE is avaliable out of the whole memory? like let''s say 256 ram .. how much % is heap?
Depends on how much your OS and other applications have already gobbled up. If no other apps are running and your OS takes, say, 32MB, then you have 224MB available as free store. Naturally, you''re not expected to use all of it.

quote:
.. and when it runs out of heap what happens ?
Most systems today have something called virtual memory, where a file is used as extra pseudo-RAM, allowing your system to pretend to have more RAM than it actually does. This allows more applications than the RAM can accomodate to run simultaneously, by writing the contents of memory of a non-active application to file (simplified explanation) and reading them back in when the app regains focus/is reactivated. Sometimes you notice a slight pause when you switch apps on some computers? That''s memory being swapped in from and out to file.

Share this post


Link to post
Share on other sites
Metal Typhoon    122
quote:
Original post by Oluseyi
[quote]Original post by Metal Typhoon
how much of this FREE STORE is avaliable out of the whole memory? like let''s say 256 ram .. how much % is heap?
Depends on how much your OS and other applications have already gobbled up. If no other apps are running and your OS takes, say, 32MB, then you have 224MB available as free store. Naturally, you''re not expected to use all of it.

quote:
.. and when it runs out of heap what happens ?
Most systems today have something called virtual memory, where a file is used as extra pseudo-RAM, allowing your system to pretend to have more RAM than it actually does. This allows more applications than the RAM can accomodate to run simultaneously, by writing the contents of memory of a non-active application to file (simplified explanation) and reading them back in when the app regains focus/is reactivated. Sometimes you notice a slight pause when you switch apps on some computers? That''s memory being swapped in from and out to file.

thank you so much now i understand this :D

Metal Typhoon

Share this post


Link to post
Share on other sites
felonius    122
Unless of course, if you write programs for consoles where there are no virtual memory. Then it is just to bad if you run out of memory - the system just crashes. Bang!


Jacob Marner, M.Sc.
Console Programmer, Deadline Games

Share this post


Link to post
Share on other sites