Operating System - HP-UX
1845166 Members
2313 Online
110237 Solutions
New Discussion

stress test virtual memory

 
Anthony deRito
Respected Contributor

stress test virtual memory


Does any one have any ideas on how I can stress test the memory management system. I would like to allocate memory so that the system will start paging out. I will monitor memory usage while performing test. I am not a C programmer so if you have a piece of code please provide it if you will.

Thanks in advance!

2 REPLIES 2
Anthony deRito
Respected Contributor

Re: stress test virtual memory

Any help would be much appreciated!

-tony
Ermin Borovac
Honored Contributor

Re: stress test virtual memory

Try the following program.

#include
int main()
{
int ret;
size_t datsiz = 2147483648;
size_t stsiz = 0;

ret = datalock(datsiz, stsiz);
if (ret == -1) {
perror("datalock");
exit(1);
}

for (;;) {
}

return 0;
}

Compile it with 'cc +DD64'. It should create a process with 2G data space (of course adjust this number based on how much memory you have on your system).

datalock() makes sure that memory is allocated and *used* (malloc() only allocates memory).