[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using Lua in an embedded hardware environment (toward a porting guide)
- From: Doug Rogers <rogers@...>
- Date: Fri, 29 Dec 2006 16:18:02 -0500
> Having some statistical informations about typical memory usage would be
> great as well: is it worth implementing special tricks to speed up
> allocation and/or limit fragmentation on the sometimes naive memory
> allocators one gets on embedded platforms? Are there some known ways to
> do this?
Alas, I cannot help with the stats. I struggled with writing my own
malloc()/realloc() when I was attaching Lua to some boot code. I had
512K to work with (program + data), so LOTS of room by the standards of
other embedded systems. I decided that a better use of my time was to
download Doug Lea's malloc():
It was little confusing at first, trying to figure out the best way to
get it integrated, but by making the sbrk/MORECORE backend return the
rest of memory on the very first call. On the next call (which doesn't
happen except when I intentionally use up all memory), it will emit a
message and fail - as in reset!
I found that the dlmalloc() allocator met my needs - but I wasn't
pushing it for performance. I suspect that tweaking it for fragmentation
will not be necessary.
Doug (not Lea)