M
Mark Seger
I'm trying to find an easy way to hog a large chunk of memory, about
4GB, thereby reducing the amount available to the rest of the system for
caches. I know I could do this by physically removing some dimms, but
the machine is too far away!
Anyhow I thought a nifty way to do this might be by using the mmap
perlio layer. I first created a large file by specifying:
open FILE, '>:mmap', '/tmp/mmap.dat' or die;
and wrote a 1GB worth of data to it. Then I opened it with:
open FILE, '<:mmap', '/tmp/mmap.dat' or die;
and did $record=<FILE> and sure enough, my mmap'd memory in
/proc/meminfo went up. However, as soon as the read finished the memory
was released and I want to hang onto it. Then I just tried playing
around with sysread on the file handle but not matter what I specified
for record size or offset it always read 7 bytes. Clearly I don't
understand the semantics of how this works and couldn't get any more
details in the documentation.
So the question is, it is possible to open my mmap file, perform some
operation on it and hold onto the memory? My intent would then be to do
a long sleep.
In addition to trying to figure out how mmap works because it does seem
to be useful, I also wonder if anyone can suggest a better way to grab
some memory and if not, so be it.
-mark
4GB, thereby reducing the amount available to the rest of the system for
caches. I know I could do this by physically removing some dimms, but
the machine is too far away!
Anyhow I thought a nifty way to do this might be by using the mmap
perlio layer. I first created a large file by specifying:
open FILE, '>:mmap', '/tmp/mmap.dat' or die;
and wrote a 1GB worth of data to it. Then I opened it with:
open FILE, '<:mmap', '/tmp/mmap.dat' or die;
and did $record=<FILE> and sure enough, my mmap'd memory in
/proc/meminfo went up. However, as soon as the read finished the memory
was released and I want to hang onto it. Then I just tried playing
around with sysread on the file handle but not matter what I specified
for record size or offset it always read 7 bytes. Clearly I don't
understand the semantics of how this works and couldn't get any more
details in the documentation.
So the question is, it is possible to open my mmap file, perform some
operation on it and hold onto the memory? My intent would then be to do
a long sleep.
In addition to trying to figure out how mmap works because it does seem
to be useful, I also wonder if anyone can suggest a better way to grab
some memory and if not, so be it.
-mark