Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Memory leak: Windows DLL build only: msg#00053

apache.logging.log4cxx.user

Subject: Memory leak: Windows DLL build only

It appears to me that there is a memory leak from tchar.h under Windows in DLL mode. Each construct/destruct cycle of a StringBuffer causes a 4 byte leak to be reported by Purify and Leak Browser.

The following code fragment - a stripped out version of tchar.h with just the offending code in it shows the problem. Compile with gcc/linux or gcc/Mac OS X and its fine. Compile with MSVC 7.1 in Multi threaded DLL mode and the process grows. Compile with MSVC 7.1 in Multi threaded or single threaded mode and its fine.

My reading of the STL (and Rogue Wave) docs says that its all fine to call init() with your own buffer, if that is the probelm which is what Purify suggests. But maybe someone else has spotted this and there is a work around for what seems to be an MS problem. I see that the code is pretty much the same in CVS so though I have only looked at 0.9.7, I guess its true of what is coming as well.

Any views/comments welcome. I am looking for a work around.

malcolm
------------------------------------------------------------------------

#include <iostream>
#include <cwchar>
#include <streambuf>
using namespace std;

#include <sys/resource.h>
#include <unistd.h>

class mstringbuf : public std::basic_streambuf<wchar_t> {
public:
typedef std::allocator<char_type> allocator_type;

~mstringbuf()
{
char_type * b = pbase();
if (b)
{
al.deallocate(b, epptr() - b);
}
}

protected:
allocator_type al;
};

class StringBuffer : public std::basic_ostream<wchar_t> {
public:
StringBuffer() : std::basic_ostream<wchar_t>(0)
{ this->init(&buffer); }

protected:
mstringbuf buffer;
};

int main(int argc, char* argv[])
{
int result=0;
for (unsigned long i=0; i<100000000; i++) {
StringBuffer sb;
}
exit(result);
}


----------------------------------------------------------------
Malcolm Melville email: malcolm@xxxxxxxxx
ixa2a ltd. malcolm@xxxxxxxxx
Software and technical services Tel: +44 1435 831159
FAX: +44 1435 830216
Enterprise Melville Limited Mobile: 07771 781478
Network and Aviation Consultancy
----------------------------------------------------------------




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation