Re: Question about Lua 5.1.3 and realloc() on life.lua
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Question about Lua 5.1.3 and realloc() on life.lua
- From: Ralph Hempel <rhempel@...>
- Date: 2008年5月02日 09:30:05 -0400
Bogdan Marinescu wrote:
Fortunately,
dlmalloc is what Newlib uses, so at least ARM platforms are OK, since
all the ARM embedded toolchains I know use Newlib. And yes,
percentages are good :)
I've written a stripped down best-fit malloc that is very fast on
ARM7 devices with very limited RAM. I still get fragmentation on
the order of 20-30%.
The typical use of pbLua on LEGO MINDSTORMS NXT is in console mode, so
there's a lot of messing around with relatively short strings.
I did review dlmalloc() but decided (perhaps foolishly) that it
was too much code for what I was doing. No doubt it works in
a lot of different environments, but all those switches ended up
intimidating me.
The binning of chunks is a great idea when you need to find a free
block. My allocator does free block coalescing whenever possible
but I should really look at using up older chunks first, like dlmalloc
does.
Sorry for the rambling post, but it's clear that deciding which
malloc to use has a lot of tradeoffs. Having written my own
allocator and spent more time testing and debugging than I ever thought
possible, I can highly recommend picking one that you know works. :-)
Worry about tuning if it's a real problem.
Ralph