[uClibc] Help Required(ucLibc0.9.20)

sandeep malik malik_mca1 at rediffmail.com
Sat Feb 19 14:35:46 UTC 2005


  
Hi....
We are using uClibc-0.9.20 and facing the problem of Memory leak.....can anyone please help us to get out of this problem....i wrote the following code to test the leakage and found that when i am freeing the memory it is not coming back to the system....and every time we are loosing some Kbytes.....Please advice me what to do....

Thanking you in advance.....
Regards,
Sandeep Malik

#include <stdio.h>
#include "types.h"
#include "SM.h"
#include "Web.h"
#include "debugmodule.h"
#include "compiletimeoptions.h"
#include<sys/types.h>
#include<sys/stat.h>
#include<sys/ioctl.h>
#include<fcntl.h>
#include<stdio.h>

#define DYNAMIC_LOADING_SUPPORTED 		1
#define	MEMORY_SHOWING				1


#if MEMORY_SHOWING

#define SHOW_MEM                                1

int procMemFD;
void Show_MemoryInit();
void List_Memory();
#endif

void TempProcess();
void main()
{
int	*t[20];	
        int                                             retVal;

#if MEMORY_SHOWING
	Show_MemoryInit();
    List_Memory();
#endif
	 
	while (1){ 
		//printf("Main: \n");
	//	usleep(5000000);
		sleep(40);
		printf("Woke from Sleep \n");
		printf("\ngoing to call TempProcess\n");
		#if MEMORY_SHOWING
		//List_Memory();
		TempProcess();
		#endif
	}
}
void TempProcess()
{
	int	*t[20];
	int i;
	
	for (i=0; i <= 7 ; i++)
	{
        	t[i] = (int *) OS_ADPT_Allocate_Memory(NULL,3553);
		
		sleep(1);
		List_Memory();
	}
	List_Memory();
	printf("\n Now going to free Just check putting back or not.....\n");
	for (i=8; i <= 10 ; i++)
	{
        	t[i] = (int *) OS_ADPT_Allocate_Memory(NULL,3553);
		t[i+3] = (int *)  OS_ADPT_Allocate_Memory(NULL,53);
	       t[i+6] = (int *) OS_ADPT_Allocate_Memory(NULL,553);	
		OS_ADPT_Deallocate_Memory(t[i]);
	}
	for(i=1; i<=6 ; i++)
	{
		OS_ADPT_Deallocate_Memory(t[i+10]);
		sleep(1);
		printf("\nIn the for Loop allocating memory\n");
	}
	sleep(5);
//	List_Memory();

	printf("\n This should be what is shown above.....\n");
	sleep(5);
	List_Memory();

}
#if MEMORY_SHOWING
void Show_MemoryInit() 
{
        procMemFD = open("/dev/ProcMemInfo", O_RDWR, 0);
        if(procMemFD < 0) {
                printf("Sorry cant open Proc Mem DRIVER!!!\n");
        } else {
                printf("Proc Mem opened with %d\n", procMemFD);
        }
}
void List_Memory()
{
        if(ioctl(procMemFD, SHOW_MEM) >= 0) {
        } else {
                printf("Memory : ioctl failed\n");
        }
}
#endif


Thanks and Regards,
Sandeep Malik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/uclibc/attachments/20050219/23f0efbb/attachment.htm 


More information about the uClibc mailing list