OS=Linux
I measure that with the tool "top".
In this simple program

main() {
  int i;
  STACK_OF(X509_NAME *) s=SSL_load_client_CA_file("cert.pem");
  scanf("%d",&i);
  sk_X509_NAME_pop_free(s,X509_NAME_free);
  scanf("%d",&i);
}

the memory in not freed (before the second scanf)
while in this simple program

main() {
  int i;
  char *s=malloc(1000000);
  memset(s,0,1000000);
  scanf("%d",&i);
  s=realloc(s,2000000);
  memset(s,0,2000000);
  scanf("%d",&i);
  s=realloc(s,3000000);
  memset(s,0,3000000);
  scanf("%d",&i);
  s=realloc(s,4000000);
  memset(s,0,4000000);
  scanf("%d",&i);
  free(s);
  scanf("%d",&i);
}

Before the last scanf the memory is freed.

-- Ivan Visconti

----- Original Message -----
From: Richard Levitte - VMS Whacker <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, April 28, 2000 7:02 PM
Subject: Re: Free Memory Problem


> How did you measure that?  On which OS?  And if relevant, with which
> implementation of malloc() and friends?
>
> You see, at least on the Unixen I've played with, the heap is just
> that, a heap of memory that grows upward.  The top will only decrease
> if the thing you free is at the current top of the heap, otherwise, it
> will just leave a hole somewhere in the middle (this hole ends up in a
> free-list that makes it possible for malloc() to reuse it for new
> memory allocations).
>
> So, what happens is that if something else is allocated after you
> loaded all those certs, the certs won't be the top things in the heap
> anymore, and freeing them doesn't decrease the apparent use of
> application memory.
>
> This is of course OS-dependent and way outside of the scope of
> OpenSSL.
>
> If someone has a better explanatoin, please send on!
>
> --
> Richard Levitte   \ Spannv�gen 38, II \ [EMAIL PROTECTED]
> Chairman@Stacken   \ S-168 35  BROMMA  \ T: +46-8-26 52 47
> Redakteur@Stacken   \      SWEDEN       \ or +46-708-26 53 44
> Procurator Odiosus Ex Infernis             -- [EMAIL PROTECTED]
>            Member of the OpenSSL development team
>
> Unsolicited commercial email is subject to an archival fee of $400.
> See <http://www.stacken.kth.se/~levitte/mail/> for more info.
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> Development Mailing List                       [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to