Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Memory management

by abubacker (Pilgrim)
on Aug 12, 2009 at 06:10 UTC ( [id://787849]=note: print w/replies, xml ) Need Help??


in reply to Re: Memory management
in thread Memory management

Yes you are correct ,
but when I am going to develop a new and small OS based on the linux kernel I have to take care all the low level parameters ,
so please help me out !

Replies are listed 'Best First'.
Re^3: Memory management
by moritz (Cardinal) on Aug 12, 2009 at 06:50 UTC
    Then Perl is too high level to deal with such details.

    I'd recommend you read a good book on operating system design, I've heard that "Modern Operating Systems" by Tannenbaum should be quite good (though never read it myself).

      Of course, reading Tanenbaum and then trying to use Linux is not necessarily for everybody :). But having a general grasp of operating systems is recommendable and I assume that Tanenbaum knows how to teach the basics of operating systems in general and the specifics of a good operating system as well.

Re^3: Memory management
by Marshall (Canon) on Aug 12, 2009 at 11:43 UTC
    The Perl memory management model is both simple and high performance.

    If you watch the memory "footprint" of a long lived Perl process, you will observe that it grows and never gets smaller. Once Perl has a hunk of memory from the OS, it will never give it back to the OS although Perl will reuse that memory for its own purposes. So a Perl process approaches a maximum size as it runs.

    It is possible nowadays to run Perl even on a small embedded system. JAVA or C# have much more complex memory models as well as complex, hard to understand performance "hits".

    Perl may or may not be a good implementation language for your system. More and more systems are built with a mixture of languages. Perl is THE "black belt" at processing text. Last year I talked with some folks who write automated commodity trading software. These guys are like 300 feet via fiber optic cable from the exchange - it doesn't get closer than that. What do these guys use to handle the text data? You got it, Perl! What do they use to drive the "middle ware"? You got it, 'C'.

      Can't say i've noticed any of my scripts memory usage growing over time, (over a few days anyway.) But then again, windows is a complete liar sometimes with regards to memory usage.

      I'm just curious, do you have an example script that produces this behaviour?
        First, if you want to look more at Windows internals using a Windows app, I would recommend, TaskInfo: http://www.iarsn.com/taskinfo.html. No I don't get any money for this recommendation.

        Anyway with TaskInfo you can see how many files and exactly which ones a process has open and details like that which aren't available in the Windows Task Manager (what's paged in/out, etc). Doing advanced things like dynamically lowering the priority of a thread within a process is possible! Whoa!

        So anyway on to your question with some code!
        I wrote this "quickie" thing...

        Run with std Windows TaskManager open and this Perl program in the command window so that you watch both at the same time.

        The Windows Task Manager is a bit weird. But this will show a clear spike in memory usage. Then you see the point that the @list has nothing in it anymore, but that won't change windows process usage. Then finally Perl ends and level drops back to what it was before. As Windows background things come and go (like virus software, there are variations, but this @list thing is big enough that the results should be clear.

        #!/usr/bin/perl -w use strict; use Data::Dumper; my @list; populate_list(\@list,10000000); countdown(10); @list = (); #list has nothing in it now countdown(10); sub populate_list { my ($lref,$num) = @_; foreach my $x (0..$num) { push (@$lref, $x); } } sub countdown { my $num = shift; while ($num--){sleep(1);print "countdown $num\n";} }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://787849]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-19 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found