[Tremor] Memory Troubles
Michael Smith
mlrsmith at gmail.com
Wed Jan 5 21:29:47 PST 2005
On Thu, 6 Jan 2005 10:38:20 +0530, Ripinder Singh
<ripinder.singh at gmail.com> wrote:
> Well I checked throughout the code and found the trouble(I suppose). I
> had mapped the function "alloca" to malloc for porting as no such
> function is supported on our platform. Checking all functions that use
> alloca, I noted that there are no free calls once the use is served.
> Can any one explain what actually is the purpose of alloca, currently
> I have put free calls for all the allocas used. Now I was able to run
> the same song with 256KB heap size(still quite large compared to say
> wma decoder with 64KB heap ). I think still some frees need to be
> adjusted. I 'll try to track them down.
alloca() is a fairly common function that most (but not all) systems
provide, sometimes under a different name. It allocates memory in the
current stack frame, so it automatically gets freed when the function
exits.
The main advantage is that it's very, very quick - it usually requires
nothing more than an addition (or subtraction) to/from the stack
pointer. Replacing it with malloc()/free() is probably not a good
idea, unless your platform REALLY has no way to do variable-sized
stack allocations.
Yes, the stack usage WILL still be quite large - as I said before, if
you're using a system where memory usage matters, you probably should
be using the lowmem-branch version of Tremor, which should get you
into the same range as your WMA decoder.
>
> Also I was wondering whether in Ogg-Vorbis the number of channels can
> exceed 2(stereo) case. Or is it necessay to support more than 2
> channels for compliance.
The number of channels can be up to (I think) 255. Most embedded
applications will have implementation-specific limits less than that -
often only supporting mono and stereo. That's fine.
Mike
More information about the Tremor
mailing list