Link to home
Start Free TrialLog in
Avatar of david.april
david.april

asked on

Memory Leak Problem with Borland 5.0.1 Multithread Libraries!

Hi there -

I have a memory leak problem with an HTTP server application that is written using Borland C++ 5.0.1. It runs fine when compiled as a single threaded app.

The memory leak shows up when the app is compiled with the
multi-threading option enabled even though there are no other threads being explicitly created.

We can reproduce the error with the following 12 lines of code:

// -------- Begin test code --------

// Test for memory leak with Borland 5.0.1 and Windows NT4.0 SP2

// Compile this without the multithread option and everything is fine.

// Compile with the multithread option (under TargetExpert),
// and it leaks memory rather quickly.

#pragma hdrstop
#include <vector>
#include <string>

main() {
   while(true) {
      std::vector<std::string> vect;
      for (int i = 0; i != 10; i++) {
        vect.push_back("Quack");
      };
   };
};

// -------- End test code --------

ASKER CERTIFIED SOLUTION
Avatar of gaohong
gaohong

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of david.april
david.april

ASKER

I am using STL (Borland's) and that appears to be where the problem is. I have since downloaded SGI's STL implementation (actually the additional port from Boris Fomitchev's page at
http://www.ipmce.su/people/fbp/stl/stlport.html) and am trying to see if it makes a difference.

FWIW, Borland has indicated that this problem is not fixed in BC5.2, but a tech there is also looking at their STL source to dig into it more.

Dave