This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

malloc failing

Hi,
I currently encounter problems with malloc.
I use microlib and configured the heap to be 32MBytes (0x02000000 bytes).
Under some special circumstances (depending on the image date we get from a CMOS) malloc fails somwhere in my image analysis when trying to allocate memory of e.g. 0x1000 bytes. I tracked the total amount of allocated memory and found out, that only 0x19000 bytes has been allocated until the call of malloc.
After each call to the image analysis functions, all allocated memory is freed, thus it should not be caused by fragmentation.

How can it be possible, that malloc fails?
May it be possible - because of a programming error -, that overwriting some data malloc uses to determine the free amount of memory, will cause such problems?

Where can I get informations on how microlib implements malloc?

Parents
  • If the variable "params" is a global variable, it should always have a fixed address.

    If the variable "params" is an auto variable, the address will depend on the current stack depth when reaching the function that contains the variable.

    But the variable should not move if you continue deeper in your call tree.

    How do you deduce that the variable moves? Looking at a named variable in the debugger? Looking at the contents of an absolute address in the debugger? Some other method? Note that auto variables are often problematic for a debugger when you continue to call new functions, since the currrent stack frame gets replaced with the new stack frame for the called function. But looking at a memory dump for an absolute address should still show the contents of the "params" struct, unless "params" happens to be located in a position where it may either be overwritten by a DMA transfer, or may be damaged by a stack overflow.

Reply
  • If the variable "params" is a global variable, it should always have a fixed address.

    If the variable "params" is an auto variable, the address will depend on the current stack depth when reaching the function that contains the variable.

    But the variable should not move if you continue deeper in your call tree.

    How do you deduce that the variable moves? Looking at a named variable in the debugger? Looking at the contents of an absolute address in the debugger? Some other method? Note that auto variables are often problematic for a debugger when you continue to call new functions, since the currrent stack frame gets replaced with the new stack frame for the called function. But looking at a memory dump for an absolute address should still show the contents of the "params" struct, unless "params" happens to be located in a position where it may either be overwritten by a DMA transfer, or may be damaged by a stack overflow.

Children