Jump to content
Sign in to follow this  
rlang

Memory Allocation Failed!

Recommended Posts

I have just gotten the C syntax errors out of my program (1019 lines) and encountered the following when linking. From what I gather on the forum, the warnings are meaningless. I have not found any documentation on the linker. I am wondering if anyone has any guidance on tracking down what caused the Memory allocation failed! message. At this point I am in a similar situation to a MICROSOFT "Unexpected Error" message; where do I start? Any guidance is appreciated.

 

C:\SBOOST\linker.exe /ld C:\SBOOST\lib libc.pic16.lib midi.obj /t 16C745 /d C:\SBoost\Samples\C\BoostC /p midi

BoostLink Optimizing Linker Version 1.6 Alpha

Warning: Unable to successfully create 'delay_us' with clock freq 4000000 Hz

Warning: argument of 'delay_10us' calls must be bigger than 1

Memory allocation failed!

 

Failed

Done

Share this post


Link to post
Share on other sites

RLang,

 

Sorry about this one :)

 

It actually means that it is not possible to allocate all the memory required for you program, ie there is not enough GPR registers on the target device.

 

I will improve the error message.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Here is my solution to the reported problem:

I received Memory allocation failed! Message when linking the following program.

 

I have narrowed down the portion of the program causing the error. The program compiles ok as shown below. If the // is removed then the Memory allocation failed! message appears. Since removing the comment only adds another 20 bytes to the string, I don’t see why the memory can not be allocated when there are 126 bytes free.

 

It appears that the problem is that there is not enough memory left in bank0 to allocate STRING2 after allocating STRING1. The other memory banks are only 80 bytes long so they can not contain STRING2.

By reversing the order of the two STRING statements below, the program linked ok with the comment removed.

 

#include <system.h>

void main()

{

const char String1 [] = {54,3, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'c', 0, 'h', 0, 'i', 0, 'p', 0, ' ', 0,

'T', 0, 'e', 0, 'c', 0, 'h', 0, 'n', 0, 'o', 0, 'l', 0, 'o', 0, 'g', 0, 'y', 0,

',', 0, ' ', 0, 'I', 0, 'n', 0, 'c', 0, '.', 0};

const char String2 [] = {92, 3, 'P', 0, 'i', 0, 'c', 0, '1', 0, '6', 0, 'C', 0, '7', 0, '4', 0, '5', 0, '/', 0,

// '7', 0, '6', 0, '5', 0, ' ', 0, 'U', 0, 'S', 0, 'B', 0, ' ', 0, 'S', 0, 'u', 0,

'p', 0, 'p', 0, 'o', 0, 'r', 0, 't', 0, ' ', 0, 'F', 0, 'i', 0, 'r', 0, 'm', 0,

'w', 0, 'a', 0, 'r', 0, 'e', 0, ',', 0, ' ', 0, 'V', 0, 'e', 0, 'r', 0, '.', 0,

' ', 0, '2', 0, '.', 0, '0', 0, '0', 0};

trisb=0;

while(1==1)

portb=1;

}

 

Memory Useage Report

====================

RAM available:302 bytes, used:126 bytes (41.8%), free:176 bytes (58.2%)

ROM available:8192 bytes, used:203 words (2.5%), free:7989 words (97.5%)

 

Successful

Done

Share this post


Link to post
Share on other sites

rlang,

 

Now fixed. Will be in release 1.7.

 

New error message will be:

"Error: Memory allocation failed - No remaining memory block big enough for:myarray in filetest.c size:258 bytes"

 

Regards

Dave

Share this post


Link to post
Share on other sites
rlang,

 

Now fixed. Will be in release 1.7.

 

New error message will be:

"Error: Memory allocation failed -  No remaining memory block big enough for:myarray in filetest.c size:258 bytes"

 

Regards

Dave

 

Hey Dave,

 

Think you could change the stack error too reflect the limitations of the target too? I remember getting a stack error when I was trying to choak the compiler, but I wasn't certain if this was the compiler complaining about its' own stack, or if it was complaining about the stack limits of the target. After looking up the specs of the selected target, I realized that the error was probably due to the max of 8 stacks availiable to the target and NOT the compiler. :)

Share this post


Link to post
Share on other sites

rlang,

 

Nice point, maybe the work "target" needs to be used a bit more to clarify what is being referred to.

 

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...