Sign in

username:

password:



Not a member?

Search code-comp



Search tips

Subscribe to code-comp



code-comp by Keywords

ARM7 | BIOS | Bug | EVM | JTAG | Linker | LOG_printf | McBSP | Profiling | Relocation | RTDX | Simulator | Target | Watch

Ads

Discussion Groups

Discussion Groups | Code-Composer | Memory problems

Technical discussions about Code Composer Studio.

  

Post a new Thread

Memory problems - thed...@yahoo.com - Jul 24 13:44:34 2008



I've recently ran into issues allocating memory for variables in my program.  At some
point, I allocate memory as follows.
BIIR = (float **)calloc(20,sizeof(float*));
    	if( BIIR == NULL )
		{
  			return false;
		}
	    
		for(i=0;i<20;i++)
		{
			BIIR[i] = (float *)calloc(5,sizeof(float));
			if( BIIR[i] == NULL )
			{
  				return false;
			}
		}

The function that these lines of code in returns a "false" since the program sees
that the variable BIIR[i] is null (specifically BIIR[17]), which leads me to believe that there
isn't enough memory to support this allocation.  

Has anyone ever had issues where there isn't enough memory on the device to support all
variables in a program?  I'm using a PEP5416 with CCSv3.1 by the way. 

------------------------------------

OMAP35x EVM jump-starts low-power apps
------------------------------------
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building
applications based on the OMAP35x architecture:http://www.DSPRelated.com/omap35x



(You need to be a member of code-comp -- send a blank email to code-comp-subscribe@yahoogroups.com )

Re: Memory problems - Dan - Jul 25 12:07:13 2008

--- In c...@yahoogroups.com, thedoctor152003@... wrote:
>
> I've recently ran into issues allocating memory for variables in my
program.  At some point, I allocate memory as follows.
> BIIR = (float **)calloc(20,sizeof(float*));
>     	if( BIIR == NULL )
> 		{
>   			return false;
> 		}
> 	    
> 		for(i=0;i<20;i++)
> 		{
> 			BIIR[i] = (float *)calloc(5,sizeof(float));
> 			if( BIIR[i] == NULL )
> 			{
>   				return false;
> 			}
> 		}
> 
> The function that these lines of code in returns a "false" since the
program sees that the variable BIIR[i] is null (specifically
BIIR[17]), which leads me to believe that there isn't enough memory to
support this allocation.  
> 
> Has anyone ever had issues where there isn't enough memory on the
device to support all variables in a program?  I'm using a PEP5416
with CCSv3.1 by the way.
>

I doubt that your actually running out of actual memory.  I think your
memory definitions just might need tweaked. Do you have a -heap option
in your linker command file?  At the top of the linker command file,
you can put something like -heap 0x800, which specifies the size of
the heap.  This is allocated in the .sysmem section, so make sure that
 you allocate that section into memory somewhere.  When you call
malloc, calloc, etc, it tries to allocate this memory from the heap. 
If you have not specified a heap section, you should see behavior like
you are seeing right now.  In your example, BIIR, the pointer to the
buffer, is going to be allocated as a normal variable (either in .bss
 for global variables, or on the stack for local variables)  But the
dynamically allocated stuff gets allocated in the heap space.  

Regards,
Dan

------------------------------------

OMAP35x EVM jump-starts low-power apps
------------------------------------
The modular and extensible OMAP35x Evaluation Module (EVM) enables developers to start building
applications based on the OMAP35x architecture:http://www.DSPRelated.com/omap35x



(You need to be a member of code-comp -- send a blank email to code-comp-subscribe@yahoogroups.com )