Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2004

Tip: Looking for answers? Try searching our database.

Diagnosing Memory usage under C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tommy Vercetti - 30 Mar 2004 18:56 GMT
I have a large (~100K lines) C++ server application that exhibits memory
 problems: after about 6 hours of high volume use, it can reach RAM
levels of 1.3GB which is unacceptable.

Most leak detection or C++ memory profiling tools are targeted at the
really blatant traditional C/C++ leaks where a certain piece of
frequently used code calls new/malloc and has no matching delete/free.

My application really isn't this simple. The bulk of my app's RAM use is
through Boost smart pointers, STL collections, and STL strings. I see
excellent profiling tools for Java/C# such as JProbe which help diagnose
such complex memory use issues but I really don't see a parallel for C++.

I've tried the leak detection system built into VC++, Purify, and a few
other tools but none of them prove fruitful.

I've manually reviewed any use of new/malloc and everything looks OK.
I'm more inclined to suspect that a data cache has grown too large, or
there is just too much of a certain kind of data in RAM. Basically, the
kind of "leaks" that are also present in Java/C# development and not the
simple C/C++ style memory leak.

Any ideas/suggestions? Would getting a Microsoft Managed C++ build of my
application help anything? A complete transition to C#/Java is obviously
way too involved at this point and is out of the question.

thanks!
Steve Waggoner - 30 Mar 2004 23:32 GMT
> My application really isn't this simple. The bulk of my app's RAM use is
> through Boost smart pointers, STL collections, and STL strings. I see
> excellent profiling tools for Java/C# such as JProbe which help diagnose
> such complex memory use issues but I really don't see a parallel for C++.

> I've manually reviewed any use of new/malloc and everything looks OK.
> I'm more inclined to suspect that a data cache has grown too large, or
[quoted text clipped - 5 lines]
> application help anything? A complete transition to C#/Java is obviously
> way too involved at this point and is out of the question.

I would see if it truely a memory leak. It might be you either fragmented
the
memory with too many small allocations or you have stl containers that have
memory still reserved.

What I did to figure this out was put all variables in one structure. See
how much
memory is used when you start the program. After 6 hours usage. Delete the
structure and reallocate it and see if your memory usage is back to normal.

If the case is too many small allocations then you have to rethink your
design.
If the case is the stl containers are hording memory look at page 77 of the
"Effective STL" book about freeing excess container capacity.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.