Solved

Memory Leak Problem with Borland 5.0.1 Multithread Libraries!

Posted on 1997-05-01
2
447 Views
Last Modified: 2013-12-14
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 --------

0
Comment
Question by:david.april
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
gaohong earned 200 total points
ID: 1163161
Do you use STL or you just give the example to show Multi thread
leaking. If you do not use STL, then you could use something
else to check the leak is from STL or multithread. If it from
multithread then you have no choice, except contact Borland, wait
for BC++5.2. If it is from STL, you might do something by either
using your own vector container or other version of STL.

hope this can help
0
 

Author Comment

by:david.april
ID: 1163162
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
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question