[uClibc] Help Required(ucLibc0.9.2x)-(Explaination)

Amit Tuljapurkar amitt at mahindrabt.com
Tue Feb 22 06:43:22 UTC 2005


Hey malik,
i apologize for not seeing the entire code below.. however yes, the 0 to
7 locations are not really released..
it looks like point A and B shall have the same mem status.. if u r
loosing memory there, perhaps u may check up the
. compatibility of the allocate and free functions.. 
. once mem is freed, how is it mapped to the free pool, since u r
working on mmu less cpu, u might be using custom mem management code.. 
 
these points r purely based on the logic, as i am unaware of the actual
h/w s/w u r using..
hth
amit.
 

-----Original Message-----
From: uclibc-bounces at uclibc.org [mailto:uclibc-bounces at uclibc.org] On
Behalf Of sandeep malik
Sent: Tuesday, February 22, 2005 9:57 AM
To: uclibc at uclibc.org
Subject: [uClibc] Help Required(ucLibc0.9.2x)-(Explaination)




Hi....

What is bugging me is, the second for loop and not the first one, where
i am doing 9 allocations out of which 3 i am freeing with in the same
loop and rest 6 i am freeing in next for loop....

Point A:
     
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);
//Doing 9 allocations of which three below are getting freed below
     OS_ADPT_Deallocate_Memory(t[i]);
}
for(i=1; i<=6 ; i++)
{
//Rest 6 allocation are freed here
     OS_ADPT_Deallocate_Memory(t[i+10]);
     sleep(1);
     printf("\nIn the for Loop allocating memory\n");
}  
Point B:


What i am saying is memory should be same when it is listed at Point A
and then again at Point B. But here i am loosing 8K of memory.... Could
you please explain me the reason for same......

Thanks and Regards,
Sandeep Malik


On Mon, 21 Feb 2005 sandeep  malik wrote :
>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
>_______________________________________________
>uClibc mailing list
>uClibc at uclibc.org
>http://uclibc.org/mailman/listinfo/uclibc


Thanks and Regards,
Sandeep Malik

 <http://clients.rediff.com/signature/track_sig.asp>  



*********************************************************
Disclaimer:

The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of MBT and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee(s).   In case you are not the desired addressee, you should delete this message and/or re-direct it to the sender.  The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of MBT.

This e-mail message including attachment/(s), if any, is believed to be free of any virus.  However, it is the responsibility of the recipient to ensure that it is virus free and MBT is not responsible for any loss or damage arising in any way from its use

*********************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/uclibc/attachments/20050222/534cce3d/attachment.htm 


More information about the uClibc mailing list