abubacker has asked for the wisdom of the Perl Monks concerning the following question:

Dear community ,
I want to write a program in which memory management is a major part.
whether perl supports memory management.
If yes show me a glance of it.


Thanks in Advance !

Replies are listed 'Best First'.
Re: Memory management
by CountZero (Bishop) on Aug 12, 2009 at 05:53 UTC
    I thought Perl was a language where you didn't have to bother yourself with such low-level matters as "memory management".

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      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 !

        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).

        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'.