[Boost-bugs] [Boost C++ Libraries] #4679: Memory Leak using Boost Threads with Indirect Usage of ADO .NET (CLR)

Subject: [Boost-bugs] [Boost C++ Libraries] #4679: Memory Leak using Boost Threads with Indirect Usage of ADO .NET (CLR)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-09-23 00:53:22


#4679: Memory Leak using Boost Threads with Indirect Usage of ADO .NET (CLR)
----------------------------------+-----------------------------------------
 Reporter: twc2102@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: threads
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
----------------------------------+-----------------------------------------
 I've noticed a significant memory leak when I use Boost Threads to
 repeatedly call a managed C++ function with an unmanaged interface. The
 managed function executes a stored procedure using ADO .NET's
 ExecuteNonQuery.

 I created an executable that only loads data into SQL Server by repeatedly
 executing a stored procedure based on information in fixed files. I make
 sure that all variables go out of scope before my executable ends with two
 lines, allowing me to see unreleased memory
 to that point

 char str [256];
 scanf_s("%s", &str, _countof(str));

 Without using any thread library, my exe would utilize 31MB of memory at
 scanf_s. Using Boost threads with a pointer to a single thread that is
 created, joined, and deleted once for 32 files, I have 72MB of unreleased
 memory. Using threadpool at http://threadpool.sourceforge.net/index.html
 with a pool of a single thread, I utilize 49MB of memory.

 If I increase the number of small files to 1,000 and increase the number
 of threads to 16, then the memory usage without a thread library is
 unchanged and the unreleased memory with a thread library can exceed 1GB.
 If I scale the size large enough, I run out of memory.

 Template Example with 72MB of unrelease memory
 {
      boost::thread *tp=0
      for (long i=0; i<32; i++) {
          tp=new boost::thread(Func)
          tp->Join();
          delete tp;
          tp=0;
      }
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4679>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC