why can't malloc large memory?

When developing video communication application on net+50 by using multi2000, I can’t allocation a large memory with “malloc” but can access these momory by write or read data. The sdram size is 16MB. I use project module locating at src\apps emplate to generate project files and don’t modify the *.lx linker file. I guess the reason for this problem is incorrect linker file, but I don’t know how to config it. Would you give me a complete example? Thanks!

You need to increase the C run time heap defined in the linker file for example like the one below: # .heap set to F22222 to facilitate large attachments

Hi all! I have an Exception 4 (memory abort) on a malloc(20). But I’m quite sure I have enough heap to do this malloc. The total amount memory I allocated before (with malloc) is about 12K. In the image.lx file the heap is set to .heap ALIGN(16) MIN_ENDADDRESS(RAM_END_ADDRESS) What does this mean exactly? RAM_SIZE is 16M. Is the format of the linker files sort of a standard, and is this documented somewhere? I can only guess what the meaning of these commands is… Has anyone experience with linker files, I would appreciate any hint! Thanks, Stefan

Well, I’ve got it. By definition, the malloc controlls the memory of the heap in a way that no exceptions may occur. If it’s out of memory it may return 0 but no other error may occur. I wrote into a region of the memory that wasn’t mallocated before. So the next malloc didn’t work correct because maybe some of the malloc’s control data was overwritten… About the linker script instructions I read in the Multi 2000 “Embedded ARM Development Guide”. The syntax used in image.lx and customite.lx is described there. What I still don’t undestand: How does the linker know in which memory section (picbase,text,syscall,etc…) it has to place which data and code. Are these standardized names for the memory sections? Or who says that variables are placed in ‘.data’, that programm code is placed in ‘.text’ and malloc can allocate memory from ‘.heap’?

That makes sense but how can you know how much memory was virtually allocated?

I was trying to figure out how much memory I can malloc to maximum extent on my machine (1 Gb RAM 160 Gb HD Windows platform). I read that maximum memory malloc can allocate is limited to physical memory.(on heap)

Also when a program exceeds consumption of memory to a certain level, the computer stops working because other applications do not get enough memory that they require.

Did you try to malloc 500k (or more) to see if your utilization goes up? On PC amount of memory is critical for CPU utilization because of virtual memory and paging file. The programs there think they have more memory than physically available and once physical memory is full CPU starts moving programs to HardDrive’s paging file, which is what causes drop in performance and the more memory you have the less paging it does and better performance it has. In embedded system there is no paging. Programs either have enough memory or not. There could be some fragmentation issues and they can affect CPU performance if you’d have a defrag thread, but not by 20% and not in your case. In your case you essentially throttling the system throughput. By lowering the system throughput, for sure, your CPU utilization will diminish.