Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: memory "release" with $#=-1

by ISAI student (Scribe)
on Jun 28, 2005 at 11:00 UTC ( #470575=note: print w/replies, xml ) Need Help??

in reply to Re: memory "release" with $#=-1
in thread memory "release" with $#=-1

I am sorry for being obtuse. Will it improve the memory usage or not, in the same scope?

Replies are listed 'Best First'.
Re^3: memory "release" with $#=-1
by dave_the_m (Prior) on Jun 28, 2005 at 12:15 UTC
    my $a = []; $a->[$_] = $_ for 0..999; $#$a = 1; # frees up approx 16000 bytes undef @$a; # frees a further 4000 bytes undef $a; # frees a further 52 bytes
    Note that this frees memory to the perl interpter, not to the OS. ie perl can reuse that memory when creating further data, but other processes can't

    update: to clarify: just doing the undef $a on its own would free up all 20052 bytes too.


      OK. That's great, I'll use it to free up memory. Thanks for all your help. -ISAI student
      One note though, if you create the array peicemail over time, then you may have smaller portions of memory allocated for the array that are not contiguous. In that case freeing the array and making a new array may not use the freed memory if the new array has larger malloc needs then the freed memory has contiguous memory segments.

        I'm pretty sure perl arrays always take up a contiguous region of memory, at least for the actual "array" part. Then again, it's just an array of pointers to SV's anyways, so I'm not sure it matters.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://470575]
[Corion]: ... the socket is done by my code. Ideally that module would not be based on callbacks ;)
[Corion]: Basically, something that decouples the HTTP parsing (+ determining whether to redirect, etc) from the IO
[Corion]: All clients I'm aware of don't do that but issue all IO themselves

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2016-12-07 15:52 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (130 votes). Check out past polls.