Dynamic Memory Allocation on the HC08?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Dynamic Memory Allocation on the HC08?

2,562 次查看
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.
标签 (1)
0 项奖励
回复
1 回复

631 次查看
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 项奖励
回复