Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: RE: Memory management
From: Nielsen Linus (ext) (Linus.Nielsen_at_elema.siemens.se)
Date: 2002-09-23


> In the last few days I've been working on a text file viewer
> app and I have a few questions concerning memory management :
> - From what I've seen in the code, there is one stack for
> each thread, and the usual size of this stack is 1kb. Isn't
> it a bit small ?

No, it isn't. If you look in the OS debug screen you will see that the
threads use max 30% of their stacks as of today. The default size is about
1K, and the memory hungry threads allocate more.

> What happens if we go over this limit ?

You will eventually get a Stkov error, if you don't crash before the kernel
detects it.

> - When we declare a global variable (not in a function), is
> the memory allocated on the stack or staticaly reserved by
> the compiler ?

Globals are, naturally, not allocated on the stack.

> - The decision was made to not use dynamic memory allocation
> but it seems to be implemented in the firmware/malloc
> directory. Should we use malloc or not ?

Malloc is still in the source tree, but is not used. Don't attempt to use
it.

> What I'm trying to do is to load the content of the file in a
> buffer. I would like this buffer to be pretty large (30kb)
> but I'm not sure how this should be done: allocated on the
> stack (we might get an overflow), global variable (memory is
> not released when we quit the app), dynamic allocation ?

If you really need 30K buffer for some reason you should allocate it
statically. The question is why you need all that memory.

/Linus



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa