Solved

Memory Leak Problem with Borland 5.0.1 Multithread Libraries!

Posted on 1997-05-01
2
402 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
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now