Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > I think I want to use of mmap and perlio

Reply
Thread Tools

I think I want to use of mmap and perlio

 
 
Mark Seger
Guest
Posts: n/a
 
      06-15-2007
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
 
Reply With Quote
 
 
 
 
Mark Seger
Guest
Posts: n/a
 
      06-15-2007
> 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.


If anyone cares, all I had to do was append mem=4g to the kernel line in
my boot loader. duh!
-mark

 
Reply With Quote
 
 
 
 
Tim S
Guest
Posts: n/a
 
      06-15-2007
Mark Seger wrote:


> 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


Hi

Simpler:

malloc() and mlock().

HTH

Tim
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IO::Select and PerlIO Peter J. Holzer Perl Misc 9 11-24-2012 08:51 AM
Guessing Encodings and the PerlIO layer sln@netherlands.com Perl Misc 2 07-28-2009 02:38 AM
PerlIO omission Bo Lindbergh Perl Misc 6 06-08-2006 10:42 PM
setting perlio layers (e.g., utf8) on "magic" ARGV file handle Dave Perl Misc 0 06-11-2005 01:18 AM
perlio problem? redhat 9, perl 5.8.0 gordon Perl Misc 3 06-27-2003 09:39 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57