BigEd / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
1 stars 3 forks source link

Fix memory waste introduced by closures #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Enabling closures caused every function to have a new tuple for the cellvars 
even if the tuple was empty.  This causes a lot of wasted RAM.

Try to change this so that if a function is normal (not a closure), the 
co_cellvars should be C_NULL and not an empty tuple.  One could check the 
co_flags for CO_NOFREE to see that the function does not have 
freevars/cellvars.

Original issue reported on code.google.com by dwhall...@gmail.com on 10 Jan 2010 at 5:39

GoogleCodeExporter commented 9 years ago
trunk403:
    ipm> import sys; sys.heap()
    (3340, 8192)
    # After GC --> 4036

trunk404:
    ipm> import sys; sys.heap()
    (2828, 8192)
    # After GC --> 3692

Closures caused loss of 512 bytes during initialization 
of which about 344 bytes were lost permanently.

Original comment by dwhall...@gmail.com on 10 Jan 2010 at 6:04

GoogleCodeExporter commented 9 years ago
trunk404 (with fix):
    ipm> import sys; sys.heap()
    (3012, 8192)

Recovered 184 bytes.

Note that the comparison of "After GC" in the previous comment isn't valid; so 
"344 
bytes were lost permanently" should be disregarded.

Original comment by dwhall...@gmail.com on 17 Jan 2010 at 7:50

GoogleCodeExporter commented 9 years ago
Fix involved setting the Code object's cellvars tuple field to NULL when the 
tuple was 
empty and accounting for a possible null pointer in frame.c and interp.c.

There is no way to test for regression on this.

System tests pass.  Ipm runs.  Mainlined directly, see r407.

Original comment by dwhall...@gmail.com on 17 Jan 2010 at 7:56

GoogleCodeExporter commented 9 years ago
Changing Milestone-r10 to Milestone-r09

Original comment by dwhall...@gmail.com on 7 Mar 2010 at 6:26

GoogleCodeExporter commented 9 years ago
Changed r09 to R09

Original comment by dwhall...@gmail.com on 12 Mar 2010 at 8:22

GoogleCodeExporter commented 9 years ago

Original comment by dwhall...@gmail.com on 13 Mar 2010 at 1:30