|
|
Choosing A Webhost: |
Memory leak: Windows DLL build only: msg#00053apache.logging.log4cxx.user
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> |
|---|---|---|
| Previous by Date: | RE: Problems with DailyRollingFileAppender, paulo . albuquerque |
|---|---|
| Next by Date: | Re: Memory leak: Windows DLL build only, Curt Arnold |
| Previous by Thread: | SocketHubAppender client, renny . koshy |
| Next by Thread: | Re: Memory leak: Windows DLL build only, Curt Arnold |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |