cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nexus6
Level 3

How can I determine the amount of physical memory (RAM) available?

The amount of RAM installed on a machine...

I see that I can get this info in the DevStudio product...

http://helpnet.installshield.com/robo/projects/HelpLibDevStudio9/IHelpPropReference.htm#Hardware

How can I get it in InstallShield MP 11.5?

Or, if there is no automatic wizardly way, can somebody tell me if/how this information can be obtained from Java?

Thanks!
Labels (1)
0 Kudos
(2) Replies
sithlord
Level 4

Java cannot make this call. You'll need to make a JNI call to the. Here are the calls you'd need to make in C to get system memory in Windows and UNIX.
Cheers,
--Will


#ifdef WIN32
MEMORYSTATUS ms;

GlobalMemoryStatus(&ms);

//Debug 1024000L 1048576L
//printf("Total physical: %lu bytes (%luMB)\n", ms.dwTotalPhys, ms.dwTotalPhys / 1048576L);
return (ms.dwTotalPhys / 1048576L);
#endif

/**
* sysconf(_SC_PHYS_PAGES) returns a long containing the number of memory pages;
* you have then to multiply by sysconf(_SC_PAGESIZE), the number of bytes
* per memory page (that varies depending from the hardware you have).
* And to divide by 1024*1024 if you need units of Megabytes :-)
*/
#ifndef WIN32
long n_phys, s_phys;
n_phys = (sysconf (_SC_PHYS_PAGES)/1024) * (sysconf (_SC_PAGESIZE)/1024);
return n_phys;
#endif
0 Kudos
nexus6
Level 3

Thanks, I appreciate the post!
0 Kudos