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++ / December 2003

Tip: Looking for answers? Try searching our database.

Concerning Garbage Collection in Managed C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim Murray - 22 Dec 2003 02:58 GMT
Hello,
  I am developing a console application in Managed C++
with Visual Studio .Net.  I am trying to learn how to
correctly destroy variables.  When I run my program, with
every added action, the memory usage increases but the
only memory being allocated in each function is for
temporary local variables, and should not persist.  
Calling the garbage collector does not seem to do anything
to clean up the memory usage.  I am currently setting each
variable back to NULL upon leaving the functions, but it
does not seem to be working.  Are variables in Managed C++
not cleaned up when they go out of scope?  Am I supposed
to take extra precautions to get them to be released?  Is
there any way for me to find out what is leaking?

Thank you for your help,
Tim
- 22 Dec 2003 03:50 GMT
Hi again,
   I got some help tracking the problem down and now know
that the variable that is leaking memory is an
OleDBDataReader - I close it, but all of the memory that
was allocated for it remains.  Any ideas on how to clear
this up?  I need to keep the database connection open.

Thanks,
Tim

>-----Original Message-----
>Hello,
[quoted text clipped - 15 lines]
>Tim
>.
0to60 - 29 Dec 2003 17:09 GMT
> Hi again,
>     I got some help tracking the problem down and now know
> that the variable that is leaking memory is an
> OleDBDataReader - I close it, but all of the memory that
> was allocated for it remains.  Any ideas on how to clear
> this up?  I need to keep the database connection open.

Are you referring to .Close()ing it or to setting the variable to null and
it being garbage collected?

If you mean .Close(), it is possible that the memory used is held onto in
case of another .Open().  If you mean you're setting the variable to null
(or it goes out of scope, or you .Dispose() it), the garbage collector runs
in a non-deterministic manner, meaning it will deallocate the memory
whenever it feels like it and you needn't be concerned.

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.