Archived

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

Ram On-System: Determing

This topic is 5821 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i know how much memory (real ram, not virtual page) is available for my app/game? Lets imagine i''m doing a rather basic chess program (which by the way i am and the player only has 24Mb of Ram and an old 3Dfx Voodoo... With OpenGL driver emulators and stuff my game will run... Now, when I allocate my data pool, if the system is already using 12Mb, i''m left with 12Mb of Ram, if I use 20Mb, there will be paging to disk, right? So, using this valuable information, I can program the core engine, so that it tries to use only the (real) ram, with zero to-hard-drive paging... I hope i made my case understandable, Seasons Greetings,

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
...You'll use virtual memory.

Virtual memory is only noticeably slower, I find, for full 3D graphics like Quake/UT.

I don't know a way to check myself, but I'm not sure you'll find a big deal.

Unless, of course, it's a real old clunker HD on ATA-33 or something...

Edited by - Anonymouse Poster on January 2, 2002 3:10:31 PM

Share this post


Link to post
Share on other sites
You cannot guarantee that the OS will not page your program to disk, ever. That is the whole purpose of an OS, it operates your system. If the OS determines that your program is not as high priority as another program, it might page it to disk, you cannot tell, so you mind as well not care.

Share this post


Link to post
Share on other sites
I''m sure the AP wasn''t suggesting HD==RAM, but for most purposes you probably aren''t going to notice too badly for a modern disk subsystem (espcially if the OS is using plenty o'' RAM for disk caching, which is where most of that OS RAM usage probably goes to). Also, idle apps get paged out first (or technically, "idle" *pages* get paged out first), so if you are writing a game, chances are you''ll be using your memory enough to keep it in RAM. Of course as Jim_Ross pointed out, this will never be guaranteed. If your game is doing excessive paging on a system with only 24MB of RAM, then either redesign the game to use less RAM, or make your minimum RAM reqs 32/64/etc.

Design of your memory layout is also critical (if you want to keep paging to a minimum). Maybe it''s okay that part of your game is paged to disk. If you design it so that things that are used together end up in the same physical pages, then you wont end up thrashing virtual memory as much as you would if things were spread all over the place.

-Brannon

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
But it would still be useful to know how much RAM is available.
Say, you have a game that uses an internal caching system for OpenGL vertex arrays (as in my case). I allocate a certain amount of RAM for the memory pool of that cache at startup. The exact amount doesn''t really matter for the function of the game, but the more, the less cache misses it will have, and performance will go up. Now, to get an idea how much I should allocate for the mempool at startup, I need an idea, of how much RAM the user has. It doesn''t make sense to allocate eg. a 256 Meg mempool, if the user has 128 Meg RAM, swapping will defeat the whole idea of the cache. But it will definitely make sense, if the user has 512 Meg RAM or more.

So I need an approximate idea, of how much RAM is available on the system, to configure my memory management heuristics.

Share this post


Link to post
Share on other sites
I would like to know how to do this sort of thing (may it just be for curiousity) in any OS. You can easily acquire this information using the Windows API (I''m sorry but I don''t recall the actual functions at the moment of writing.)
I do not know how to get this information under say, Mac OS 9 or X, Linux/Unix etc and would appreciate any informative reply on this topic.

--
Pelle "Muusu" Lindstrand
pelle.lindstrand@swipnet.se

Share this post


Link to post
Share on other sites

What you''re after is the GlobalMemoryStatus() and GlobalMemoryStatusEx() Windows API calls.


Unfortunately though, calls like VirtualProtect() and VirtualLock() will only truely commit physical RAM on NT based kernels so knowing how much physical RAM there is only useful as general guide, for example for making sure a machine meets the minimum specifications for your game.

About all you can do is manual page touching to try and trick the Win9x kernel into making certain pages stay commited.


--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites