This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to see which part of the code/variable is using more Memory ?

Hi.

I am using the NRF52 Development board, on Keil uVision, to implement a C program that uses Dynamic Structs. The Structs re-size themselves ( by increasing their capacity by 2 time ) whenever more elements need to be appended to them. The code can be thought of as follows:

int main(){

for (int i=1;i<=1000;i++){
"Initialize Dynamic Structs"
.
.
.
"Do Some Computations"
.
.
.
"De-allocate memory from Dynamic Structs using free command"
}
return 0;
}

I am de-allocating memory at the end of the for loop but somehow I keep running out of memory. I know that the program does not require large amounts of memory as the Dynamic Structs only hold a few floating point values.

Is there some way I can see which particular variable I am missing and not de-allocating memory from or is there a way I can see where the memory is being utilized the most ?

Thank you.

P.S: I have kept the Stack size at 8kB and the Heap size at 52kB.

Related