Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Memory allocation functions

by vinoth.ree (Monsignor)
on Feb 02, 2009 at 10:31 UTC ( [id://740652]=perlquestion: print w/replies, xml ) Need Help??

vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:

Why there is no memory allocation function in perl ?

Replies are listed 'Best First'.
Re: Memory allocation functions
by moritz (Cardinal) on Feb 02, 2009 at 10:33 UTC
    Because memory allocation and freeing is handled by perl automatically for you.
Re: Memory allocation functions
by cdarke (Prior) on Feb 02, 2009 at 12:34 UTC
    There is! You can get memory as a scalar, an array, or a hash. Like so:
    my $scalar; my @array; my %hash;
    That memory is dynamic and managed by perl itself, so you don't need to remember to free it (usually) and you don't need to remember how much memory to allocate. Great isn't it!
      Yes, for sure. But please keep in mind that in case of complex data structures some circular references are not detected properly. In this case memory will still remain allocated.
Re: Memory allocation functions
by Lawliet (Curate) on Feb 03, 2009 at 00:59 UTC

    Who wants to worry about allocating memory when there are bigger problems to handle? As others have already stated, Perl does the allocating for you. This lets you think about the logic of the program and such.

    And you didn't even know bears could type.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-07-14 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.