delorie.com/archives/browse.cgi | search |
> From: CBFalconer <cbfalconer AT yahoo DOT com> > Newsgroups: comp.os.msdos.djgpp > Date: Fri, 12 Apr 2002 22:17:04 GMT > > First, nmalloc seems to have had no faults shown up with this. It > appears to handle this continuous realloc about 2 to 4 times > faster, and to use less memory in the aggregate. Note that > evilalgo segfaulted with an input parameter of 45000, while > nmalloc lets it handle at least 100000 without squealing (with my > memory constraints). The segfaults are not the important factor here, and might even hide the actual performance issue (memory efficiency) from view: the program crashes because it doesn't test the pointer returned by realloc before dereferencing it. It is much better to modify the code slightly to test whether realloc returns NULL, and if so, print the iteration count (and/or the amount of memory it succeeded to allocate) and exit. Then you'd have a more accurate quantitative measure of the memory overhead enforced by the kind of ridiculously bad reallocation code such as the one used by this program.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |