Re: where does the memory go?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Colin Taylor wrote:
> This little program gobbles up over 2megs of RAM, and won't give it back.

Jacques Deschenes fixed his memory.e file
and the new version is now available as memory.zip
on the User Contributions page.

Using the fixed version with Colin Taylor's example program
I got somewhat inconsistent results. In a Win95 DOS window,
the example program showed 0 memory used. When I rebooted
in pure DOS mode, it showed 102K used, then it jumped
to 1.2 Mb on the next iteration and stayed there.

Here's what is happening:

The line that says:
        seq = repeat({1}, 25000)  -- make large sequence

will use a little over 100K (25000 times 4 bytes), because
there will be 25000 pointers to a single copy of {1}.
That would explain the first 102K value I saw.

Later, the example calls function xyz() to compute:

     seq * 1

and return it as a result.

Unfortunately, the result of s * 1 will have 25000 *separate* copies of {1}
rather than 25000 pointers to a single shared copy. Instead of using
4 bytes per copy, it will need much more. There are several pieces of
overhead information stored for each sequence. 1.2M/100K = a factor of
12. This would imply that {1} uses 12*4 = 48 bytes. That is too high.
It's more like 32 bytes, but for efficiency the storage allocator may be
grabbing more from the O/S than it immediately needs. Once it grabs it,
it won't return it. It will keep it for possible further use in the Euphoria
program.

Regards,
   Rob Craig
   Rapid Deployment Software

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu