Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

CCS/OMAP-L138: Big memory leak

$
0
0

Part Number:OMAP-L138

Tool/software: Code Composer Studio

Hi all,

I have a series problem with memory on ompl138, that the program.

#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *file;
int *var1,*var2,*var3;
int *data=(int *)malloc(1*sizeof(int));
*data=5;
file=fopen("data.txt","w+");
var1=(int *)malloc(1*sizeof(int));
*var1=5;
if (fwrite(data, sizeof(int), 1, file)!=1)
{
    printf("wrong file");
}

var2=(int *)malloc(1*sizeof(int)); //address very far in 0xc0000138
*var2=3;
fclose(file);
var3=(int *)malloc(1*sizeof(int)); //also be normal
*var3=7;;
return 0;
}

var1:0xc0000018

var2:0xc0000138

var3:0xc0000028

why is var2 allocated at very far memory where all this memory was gone?
Is this normal ? does fwrite use heap?

I am using ccsv5.5 simulator I upload with file please help.(Please visit the site to view this file)

regards,

elmenshawy


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>