Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2003, 06:58 AM
Registered User
 
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Memory leak in GetInput() function of MSComm in Vi

Please help!!!

Has anyone noticed that there is a memory leak in GetInput() function of MSComm? Consider the following code (assume that connection already existed and is working fine):

COleVariant ovData;
for (int i=0; i<500000; i++)
{
  ovData = m_mcComm1.GetInput();
}

I noticed that everytime when I executed the above code, my PC's memory usage will increase about 10 MB (I got the memory usage information from Windows Task Manager).

So, after several round of testing, I decided to add a new line of code after GetInput() to free the memory occupied:

COleVariant ovData;
for (int i=0; i<500000; i++)
{
  ovData = m_mcComm1.GetInput();
  SysFreeString(ovData.bstrVal);
}

This help to reduce the memory leak, but it still happen (increase about 4K - 10K everytime the code is executed).

I wonder is it something to do with my code, or I have missed out some important setting for MSComm, or is it a bug in GetInput() function?

Your help is very much appreciated. Many thanks.

 
Old August 24th, 2004, 09:22 AM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solution at the link below...

http://www.devboxforums.com/showthread.php?t=229






Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory leak in a loop neilsands Java Basics 4 March 17th, 2010 05:59 AM
Looking for Memory Leak Advice Bill_Thompson Visual C++ 0 October 16th, 2007 05:42 PM
IE Memory Leak Jman82 BOOK: Professional Ajax ISBN: 978-0-471-77778-6 0 July 6th, 2006 05:22 PM
Memory Leak in ADO Seeja Pro VB Databases 1 December 27th, 2004 07:28 PM
Think I have a memory leak, need advice grantmeans Classic ASP Databases 1 March 12th, 2004 03:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.