in reply to Re: Unexplained memory hogging
in thread Unexplained memory hogging

99.9% of the time, I am very very very happy that Perl is managing memory for me, letting arrays or hashes grow transparently without myself having to take care of it.

I certainly do not regret the time when I had to do myself mallocs, callocs, reallocs, frees or memsets each time I wanted to use dynamic memory allocation. Well, to tell the truth, I am still using C once in a while, and that helps me knowing how happy I am using Perl instead of C most of the time. No problems with null or dangling pointers, no memory leak (except for special cases such as circular or reciprocal references), no core dump or segmentation fault (or almost never), no out of bound array, and so on and so forth, gosh, Perl is so much nicer than C.

No, I really disagree with you. If Perl were to introduce mallocs and its siblings, I would certainly go back to other dynamic languages I have been using before Perl (TCL, Python) or straight to newer ones such as Ruby and others.

Besides, I don't remember for sure and I haven't tried recently and I don't really have time right now to test, but I am not really sure that a free in a C program freeing some memory returns it to the OS. I would think that there are some OSes where it is the case, but probably not the majority of them. But I may be wrong on this last point, I don't remember having tested extensively, I usually did not have any serious data size problem at the time I was using C intensively.

Replies are listed 'Best First'.
Re^3: Unexplained memory hogging
by zentara (Cardinal) on Aug 23, 2014 at 12:57 UTC
    but I am not really sure that a free in a C program freeing some memory returns it to the OS.

    I stand corrected. In C too, there is no guarantee memory will be returned to the system and make the program smaller.

    From gnu libc free :

    "Occasionally, free can actually return memory to the operating system and make the process smaller. Usually, all it can do is allow a later call to malloc to reuse the space. In the meantime, the space remains in your program as part of a free-list used internally by malloc."

    So it seems that it is not just an interpreted language problem.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh