delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/09/15/01:16:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 15 Sep 2002 06:11:18 +0100
From: Danny Smith <dannysmith AT clear DOT net DOT nz>
Subject: Re: Memory Leak - DLL problem
To: tsanyal AT yahoo DOT com
Cc: Cygwin <cygwin AT cygwin DOT com>
Reply-to: Danny Smith <dannysmith AT users DOT sourceforge DOT net>
Message-id: <000101c25c76$55e45980$a899a7cb@DANNY>
MIME-version: 1.0
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Priority: 3
X-MSMail-priority: Normal

Don Sharp - Re: Memory Leak - DLL problemRe: Memory Leak - DLL problem
From: Don Sharp <dwsharp at iee dot org>
To: gnuwin32 <cygwin at cygwin dot com>
Date: Sat, 14 Sep 2002 21:13:56 +0100
Subject: Re: Memory Leak - DLL problem
References: <20020914194429 DOT 961 DOT qmail AT web10003 DOT mail DOT yahoo DOT com>



Tirth Sanyal wrote:
>
> Hi,
>
> I have been encountering a strange memory leak problem
> in my code which has prompted me to write a small
> program to isolate and demonstrate it. I have pasted
> the code at the bottom of the email.
>
>
> - In a DLL say libfoo, I define and export a class
> Base and also export a function "foo" whose interface
> is the following:
>   Base* foo(void)
>
> - "foo" instantiates an object of the class Base and
> returns a pointer to this object.
>
> - In my application (which has the main routine) I
> load the dynamic library libfoo, call function "foo"
> in it , get the pointer to the newly created object
> and immediately call "delete" on this pointer.
>
> - The destructor function of the class Base contained
> in the libfoo DLL is called.
>
>


There is an article called 'DLL Maintenance Made Easy'  by Geoff
Vandegrift . It used to be at
www.devx.com/free/mgznarch/vcdj but best to do a Google search.

It explains, among other things, how to  "wrap" memory allocations and
de-allocations so that you don't get leakage problem from allocating
memory on one heap and de-allocating in another.

Danny


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019