|
From: Dave D. <dde...@es...> - 2005-07-08 08:58:06
|
Ethan Merritt <merritt@u.washington.edu> writes: > On Wednesday 06 July 2005 02:36 pm, Juergen Wieferink wrote: >> But I have placed the "#ifdef" quite funny, did you notice? > > I noticed. But then, we *had* been discussing whether to remove > the conditional coding around string variables. I figured you > were just off to a quick start :-) > That reminds me... there's a couple of memory/cleanup issues been mentioned recently, and IIRC, there used to be a problem with memory leaks if SIGINT is sent during a plot, since the exact state is unknown, and so data structures cannot safely be traversed and freed. I was wondering if there's a case for some sort of garbage collection. Nothing sophisticated like moving memory around, updating pointers, etc. Just simple reference counting (probably). Perhaps something along the lines of: allocated blocks are kept in linked lists : say a list of "permanent" blocks (eg udf's), and a list of transient blocks (allocated during a plot, for example). At end of a plot, everything in the transient list is reclaimed. items can have a reference count (eg for strings, rather than making a copy, just increase the ref count on copy, and decrease it when the string goes out of scope) items can have cleanup routines. - eg for the recent issue with c++ destructors, the cleanup routine could be a c++ fn to cleanup objects - cleanup routine for an 'at' can in turn free string literals, etc. Need to be a little careful with registration of non-trivial objects, to make sure things are atomic wrt SIGINT. But I think it should be do-able. All the allocation used to go through a common routine, so it shouldn't be hard to intercept all allocs and frees. dd -- Dave Denholm <dde...@es...> http://www.esmertec.com |