summaryrefslogtreecommitdiff
path: root/py/gc.c
AgeCommit message (Collapse)Author
2015-09-04py: Eliminate some cases which trigger unused parameter warnings.Damien George
2015-07-14py: Improve allocation policy of qstr data.Damien George
Previous to this patch all interned strings lived in their own malloc'd chunk. On average this wastes N/2 bytes per interned string, where N is the number-of-bytes for a quanta of the memory allocator (16 bytes on 32 bit archs). With this patch interned strings are concatenated into the same malloc'd chunk when possible. Such chunks are enlarged inplace when possible, and shrunk to fit when a new chunk is needed. RAM savings with this patch are highly varied, but should always show an improvement (unless only 3 or 4 strings are interned). New version typically uses about 70% of previous memory for the qstr data, and can lead to savings of around 10% of total memory footprint of a running script. Costs about 120 bytes code size on Thumb2 archs (depends on how many calls to gc_realloc are made).
2015-04-16py: Convert occurrences of non-debug printf to mp_printf.Damien George
2015-04-03py: Make heap printing compatible with 16-bit word size.Damien George
2015-02-07py: Put mp_sys_path, mp_sys_argv and gc_collected in mp_state_ctx_t.Damien George
Without mp_sys_path and mp_sys_argv in the root pointer section of the state, their memory was being incorrectly collected by GC.
2015-01-12py, unix, lib: Allow to compile with -Wold-style-definition.Damien George
2015-01-11py: Add (commented out) code to gc_dump_alloc_table for qstr info.Damien George
2015-01-08Remove obsolete bss-related code/build featuresstijn
GC for unix/windows builds doesn't make use of the bss section anymore, so we do not need the (sometimes complicated) build features and code related to it
2015-01-07py: Put all global state together in state structures.Damien George
This patch consolidates all global variables in py/ core into one place, in a global structure. Root pointers are all located together to make GC tracing easier and more efficient.
2015-01-01py: Make GC's STACK_SIZE definition a proper MICROPY_ config variable.Damien George
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-11-05py: Fix some macros defines; cleanup some includes.Damien George
2014-10-31py: Make gc.enable/disable just control auto-GC; alloc is still allowed.Damien George
gc.enable/disable are now the same as CPython: they just control whether automatic garbage collection is enabled or not. If disabled, you can still allocate heap memory, and initiate a manual collection.
2014-10-24py: Improve memory usage debugging; better GC AT dumping.Damien George
In unix port, mem_info(1) now prints pretty GC alloc table.
2014-10-23py: Properly free string parse-node; add assertion to gc_free.Damien George
2014-10-23py: Clean up edge cases of malloc/realloc/free.Damien George
2014-10-17py: Add more debug printing code in gc_dump_alloc_table.Damien George
2014-10-16py: Take gc_pool_start out of bss section, to reclaim 1st block of heap.Damien George
2014-10-15py: Fix GC realloc issue, where memory chunks were never shrunk.Damien George
Previously, a realloc to a smaller memory chunk size would not free the unused blocks in the tail of the chunk.
2014-08-28py, gc: Further reduce heap fragmentation with new, faster gc alloc.Damien George
The heap allocation is now exactly as it was before the "faster gc alloc" patch, but it's still nearly as fast. It is fixed by being careful to always update the "last free block" pointer whenever the heap changes (eg free or realloc). Tested on all tests by enabling EXTENSIVE_HEAP_PROFILING in py/gc.c: old and new allocator have exactly the same behaviour, just the new one is much faster.
2014-08-28py: Reduce fragmentation of GC heap.Damien George
Recent speed up of GC allocation made the GC have a fragmented heap. This patch restores "original fragmentation behaviour" whilst still retaining relatively fast allocation. This patch works because there is always going to be a single block allocated now and then, which advances the gc_last_free_atb_index pointer often enough so that the whole heap doesn't need scanning. Should address issue #836.
2014-08-22py: Speed up GC allocation.Damien George
This simple patch gives a very significant speed up for memory allocation with the GC. Eg, on PYBv1.0: tests/basics/dict_del.py: 3.55 seconds -> 1.19 seconds tests/misc/rge_sm.py: 15.3 seconds -> 2.48 seconds
2014-08-08py: Fix bug where GC finaliser table was not completely zeroed out.Damien George
This was a nasty bug to track down. It only had consequences when the heap size was just the right size to expose the rounding error in the calculation of the finaliser table size. And, a script had to allocate a small (1 or 2 cell) object at the very end of the heap. And, this object must not have a finaliser. And, the initial state of the heap must have been all bits set to 1. All these conspire on the pyboard, but only if your run the script fresh (so unused memory is all 1's), and if your script allocates a lot of small objects (eg 2-char strings that are not interned).
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-30Try not to cause a MemoryError when raising an exception during nterrupt ↵Dave Hylands
handling. Step 1 fixes #732
2014-06-21py: Include mpconfig.h before all other includes.Paul Sokolovsky
It defines types used by all other headers. Fixes #691.
2014-06-18gc: Turn off debugging info againstijn
2014-06-18gc: Keep debug statements at beginning of scope where possiblestijn
2014-06-16gc: More verbose debuggingstijn
Add more DEBUG_printf statements to trace gc behaviour
2014-06-13py, gc: Revert ret_ptr to void*, casting to byte* for memset.Damien George
2014-06-13gc: Use byte* pointers instead of void* for pointer arithmeticstijn
void* is of unknown size
2014-06-05modgc: Implement return value for gc.collect(), enable on Unix.Paul Sokolovsky
2014-05-10py: Compress a little the bytecode emitter structure.Damien George
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-04-26py, gc: Only zero out the extra bytes at the end of the heap chunk.Damien George
This is a small optimisation to zero out only the additional bytes that the caller did not ask for.
2014-04-25Merge branch 'master' of github.com:micropython/micropythonDamien George
2014-04-25py, gc: Zero out newly allocated blocks in the GC.Damien George
Also add some more debugging output to gc_dump_alloc_table(). Now that newly allocated heap is always zero'd, maybe we just make this a policy for the uPy API to keep it simple (ie any new implementation of memory allocation must zero all allocations). This follows the D language philosophy. Before this patch, a previously used memory block which had pointers in it may still retain those pointers if the new user of that block does not actually use the entire block. Eg, if I want 5 blocks worth of heap, I actually get 8 (round up to nearest 4). Then I never use the last 3, so they keep their old values, which may be pointers pointing to the heap, hence preventing GC. In rare (or maybe not that rare) cases, this leads to long, unintentional "linked lists" within the GC'd heap, filling it up completely. It's pretty rare, because you have to reuse exactly that memory which is part of this "linked list", and reuse it in just the right way. This should fix issue #522, and might have something to do with issue #510.
2014-04-25py, gc: Fix old gc_realloc for case when NULL is passed in as ptr.Damien George
2014-04-20gc: gc_realloc(): Fix byte-to-block calculation.Paul Sokolovsky
2014-04-20py, gc: Further simplify coding-style of gc_realloc.Damien George
No logic changes, just coding style to make it easy to read.
2014-04-20gc: "new" gc_realloc: Rewrite in plain C, fixing bunch of bugs.Paul Sokolovsky
There were typos, various rounding errors trying to do concurrent counting in bytes vs blocks, complex conditional paths, superfluous variables, etc., etc., all leading to obscure segfaults.
2014-04-20gc: Recover simple gc_realloc implementation, make easier to switch between.Paul Sokolovsky
2014-04-09gc.c: Remove superfluous typedef (bute defined in misc.h).Paul Sokolovsky
2014-04-08py: Improve GC locking/unlocking, and make it part of the API.Damien George
2014-04-05Improve GC finalisation code; add option to disable it.Damien George
2014-04-05Merge pull request #425 from iabdalkader/delDamien George
Implement del
2014-04-05Move del to localsmux
2014-04-03Implement delmux
2014-04-02gc: Uses uint defined in misc.h.Paul Sokolovsky
2014-04-02py: Fix up so that it can compile without float.Damien George