tdinger@hiredgun.East.Sun.COM (Tom Dinger - Sun BOS SPA) (02/28/91)
I believe I have found a small memory leak in Perl, in 4.0 Beta, but it likely has been there a while. Actually, it is probably just a trickle...;-) The setenv() function (called from stabset() (called from do_assign)) throws away the old environment string for a particular variable, when it replaces a value with a new one. It does _not_ free it. Most likely it does not free it, because Perl may not have allocated it. At start-up, the 'environ' variable is intialized for the application by "magic", and it may not be safe to assume that one can free the entries. But for a program that assigns to elements of %ENV, this can cause loss of memory. Now you may think that most perl scripts do not manipulate %ENV very much, so a little memory lost is no big deal, but I am one of those unfortunate persons who spend significant amounts of time in DOS-land, where memory is precious. One way around this is to reallocate the contents of 'environ' at start-up, so that perl knows the elements can be freed later. Then setenv() can free the memory for an element being replaced or deleted. I only came across this while getting Perl to compile and run using the Watcom 8.0 C compiler for DOS, which promises to produce code _at least_ 10% smaller than Microscoft C -- that is non-trivial, when you consider that Perl needs at least HALF of the available memory for its code! It "almost" works, by the way. And Larry, Thanks for Perl! TD ---------------------------- Tom Dinger consulting at: TechnoLogics, Inc. Sun Microsystems Internet: tdinger@East.Sun.COM (508)486-8500 (508)671-0521 UUCP: ...!sun!suneast!tdinger Tom Dinger consulting at: TechnoLogics, Inc. Sun Microsystems Internet: tdinger@East.Sun.COM (508)486-8500 (508)671-0521 UUCP: ...!sun!suneast!tdinger