[uClibc] Help Required(ucLibc0.9.20)
sandeep malik
malik_mca1 at rediffmail.com
Mon Feb 21 15:58:14 UTC 2005
Hi....
I am runring the following sample code using uClibc. But everytime the code completes one execution 8K(2 pages) of memory are gone...i am running this code on a board w/o MMU...so i am using malloc instead of malloc-simple or malloc-standard....i tried code with uClibc 0.9.20, uClibc 0.9.25 and even uClibc-0.9.27 but still results were same....can any one please help me to get out of this and help me understand what's happening here.......
Thanking you in advance....
regds,
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 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];
pthread_t tThread;
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++)
{// Using a wrapper for malloc
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]); //wrapper for free
}
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/20050221/f5ba1d8d/attachment-0001.htm
More information about the uClibc
mailing list