Error: Call to malloc failed. Memory exhausted.


Why does my test fail with an error indicating memory exhausted?


When a pointer is used that points to a structure outside of the area that VectorCAST has allocated, this causes a behavior that is compiler dependent and thus unpredictable because the heap allocation method does not specify what happens if memory before or after the allocated memory is changed. Your case was memory exhausted, other possibilities are corruption of data, or a crash.

It is very important to check for...

  1. Structure casting in the function under test. If a cast is used and the structure that is cast to is bigger than the original, it is necessary to use user code to allocate the structure.
  2. Function under test takes a pointer argument. If the function just writes to that pointer, <<Alloc 1>> is needed. If it writes to elements of that pointer, larger allocs will be needed. If it writes before the pointer, user code is needed.

With VectorCAST/Ada it is not usually necessary to inspect the code. If there is a problem, Ada’s strong typing will cause a run time error and corrective measures can be taken. With C/C++ that is not the case and the code must be inspected.

Article ID: 1301
Last updated: 2019-10-02
Revision: 2
VectorCAST -> Troubleshooting -> Error: Call to malloc failed. Memory exhausted.