Dynamic Memory Allocation on the HC08?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic Memory Allocation on the HC08?

2,222 Views
rhinoceroshead
Contributor I
Hello,
 
I'm using the GP32 and the CodeWarrior IDE, programming in C.  I know this device doesn't have all that much RAM (512 bytes), but I was hoping to use malloc() instead of a global variable for some small string parsing.  When I compile, I get an error that says, "Out of allocation space in segment RAM at address 0x104".  Using malloc() is no problem on devices that have more memory.  Just to confirm, I increased the RAM size in the .prm file and then the error went away.  It seems that CodeWarrior wants to allocate more RAM for the heap than the GP32 device even has.  Somewhere, there has to be a place that I can reduce the heap size, but I'm not finding it.  Has anyone done this before?
 
Thanks in advance.
Labels (1)
0 Kudos
1 Reply

291 Views
CrasyCat
Specialist III

Hello

First note I would not recommend using dynamic memory allocation at all in a  HC08 project, due to the limited amount of memory available.

Beside that, the default heap size is defined as 2000 bytes.
If you really want to use dynamic data allocation and wants to use a smaller heap:

 - Open file libdefs.h in a text editor
 - Change LIBDEF_HEAPSIZE to a smaller value
 - Rebuild the library 

But once again I would not recommend using dynamic memory allocation in HC08 application.

CrasyCat

0 Kudos