This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Appro DM368 Memory leak while writing data in SD card

Hi,

I have developed a sample program in which I have allocating a buffer of 10 MB and writing buffer into SD card. After writing code I am closing file and free allocated buffer of 10 MB. Surprisingly even after closing the application 10 MB memory free is not reflected in /pfoc/meminfo. For all subsequent execution of same application doesn't leak additional 10 MB memory but same time holding 10 MB memory of the first-time execution. No other application is running along with this application.

I am using DM36x IPCamera RDK v. 4.1 V based on Linux Kernel 2.6.37. Please let me know how to resolve it.

Following is the application code.

//======================================Code Start============================================

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

#define BUF_SIZE 1024 * 1024 * 10
#define FILE_PATH "/mnt/mmc/file1.txt"

unsigned char *arr;

int main()
{
int write_bytes;
int i;
FILE *fp;

arr = (unsigned char *)malloc((BUF_SIZE * sizeof(unsigned char)) + 1);
for (i = 0; i < BUF_SIZE; i++)
arr[i] = (unsigned char)i;

fp = fopen(FILE_PATH, "wb");
if(!fp)
{
printf("Error in opening the location\n");
exit(EXIT_FAILURE);
}

write_bytes = fwrite(arr, 1, BUF_SIZE, fp);
fclose(fp);
printf("bytes = %d\n\n\n", write_bytes);

free(arr);

return 0;
}

//======================================Code End============================================

Following is the snapshot for Memory consumption before executing program

Following is the snapshot for Memory consumption after executing program

Thanks,

--HK