From: Brent W. <we...@aj...> - 2000-09-06 23:56:13
|
Eric said: *********************** > Solultion 3 - "Adaptive allocation" suggested by George > > Retain the doubling algorithm until an attempt to allocate > memory fails. When that occurs, reduce the growth by > halves until the allocation succeeds: I have an implementation of (basically) this adaptive allocation algorithm. My implementation uses the following algorithm: attempt to allocate 2*(oldsize + appendsize) on failure, attempt to allocate oldsize + (2 * appendsize) + TCL_MIN_GROWTH on failure, panic *********************** Cool - thanks for the patch! The bulk of it is the realloc and attempt variations. Your adaptive algorithm isn't quite as nifty as the one that repeatedly halves the request space as mentioned in "Solution 3", but I can also see the charm in making a single second attempt. For folks that glazed over the patch, the TCL_GROWTH_MIN_ALLOC constant is 1K. This is there to give some extra room when small amounts are added to a string. -- Brent Welch <we...@aj...> Scriptics has become "Ajuba Solutions" http://www.scriptics.com => http://www.ajubasolutions.com -- The TclCore mailing list is sponsored by Ajuba Solutions To unsubscribe: email tcl...@aj... with the word UNSUBSCRIBE as the subject. |