From: Philipp K. K. <pk...@sp...> - 2012-12-29 10:04:03
|
On 29.12.2012 07:37, Raphael Neider wrote: > Hi, > >> I'm not sure and I haven't checked either, but I guess that you get >> dangling pointers if they are freed. Maybe this only was true at some time >> in the past, maybe it still is. I guess if you look at the freeAsmop >> history you'll find a version that had free removed. Perhaps the memory >> can be freed now, it's worth a try. > > We had a discussion on memory leaks discovered by Valgrind several > months ago. Basically, sdcc is a short running program, which is > supposed to handle rather small input files and convert them into > equally rather short output. We thus simply do not care to release all > allocated memory for two reasons: > > * performance (releasing thousands of objects can and does take > considerable time; letting the OS simply cleanup the whole virtual > memory associated with the program at its exit is much faster) > * safety (as Maarten pointed out, dangling pointers could result in > premature program termination; I am aware of the fact that this also > covers programming errors, but still the current approach seems to > work pretty well). For safety, we could do reference counting for the asmops. I'll have to look into this more closely, but with the new register allocator, we can easily call aopOp a few thousand times per iCode by default (and with the --max-allocs-per-node 1000000 I use when optimization matters, it can easily be a few million times). So a memory leak here could matter. Philipp |