SDCC and malloc() - allocating much less memory than is available
Posted
by
Duncan Bayne
on Stack Overflow
See other posts from Stack Overflow
or by Duncan Bayne
Published on 2013-06-27T23:29:35Z
Indexed on
2013/07/02
23:06 UTC
Read the original article
Hit count: 245
When I run compile this code with SDCC 3.1.0, and run it on an Amstrad CPC 464 (under emulation, with WinCPC 0.9.26 running on Wine):
void _test_malloc()
{
long idx = 0;
while (1)
{
if (malloc(5))
{
printf("%ld\r\n", ++idx);
}
else
{
printf("done");
break;
}
}
}
... it consistently taps out at 92 malloc()s. I make that 460 bytes, which leads me to a couple of questions:
What is malloc() doing on this system? I was sort of hoping for an order of magnitude more storage even on a 64kB system
The behaviour is consistent on 64kB systems and 128kB systems; do I have to perform some sort of magic to access the additional memory, like manual bank switching?
© Stack Overflow or respective owner