CBFalconer wrote:
I don't know what system you are using, but many C systems have great problems with free() when there are many items to free. I would expect that gpc's new/dispose is using the C runtime malloc/free implementation, but I am prepared for Frank to refute this.
Yes, it is (by default, it can be changed at link time, as you described, or at run time, using GetMemPtr etc.).
For DJGPP I wrote a replacement, called nmalloc, and available at:
http://cbfalconer.home.att.net/download/nmalloc.zip
which avoids this problem, because free is now an O(1) process in place of O(n). The original O(n) expands to O(n**2) when many items are to be freed.
[...]
Aside to Frank: If I am correct, you are perfectly free to incorporate nmalloc in the gpc system. It also detects a subset of possible trashed arenas, and raises SIGABRT in those cases.
I tried it under Linux, and didn't make a significant difference. I didn't try it on other systems, but have you tried it on anything else but DJGPP?
Perhaps it's a problem on some systems, but apparently not all. That's one reason why I wouldn't include it by default. Another one is that people might want to link in an alternative malloc (perhaps another optimized version, or a GC one, etc.). Also, the dependency on sbrk might be problematic (it's neither POSIX not C standard; most Unix systems should have it, also DJGPP, but I'm not sure about, e.g., Windows; it's a single routine, but I think one that can't be easily worked around on systems with substantially different memory management).
However, if you like I can put your packages in `contrib' on the web site. (Or you can get an account if you plan to upload or change your contributions regularly.)
BTW, there were a few compile problems (conflicts with `ulong' and `roundup'; uses `fakesbrk' by default; includes "cokusMT.h" while the zip contains a file `cokusmt.h'; works only on case-insensitive file systems), and some little Makefile problems -- it omits `-lm' (and sets, but doesn't use `CFLAGS', so `-lm' can't be added there), and it adds `.exe' which is at least strange on non-Dos systems; I think even gcc on DJGPP adds it automatically.
Frank