CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Posts
    146

    Why my dataset doesn't release memory!!

    Hi all,
    I see there are a lot of question about it ...but no way to solve this problem....
    In code like :
    using (Dataset ds = new dataset())
    {
    .........some ds stuff................
    }

    even if
    ds.dispose()
    or
    ds=null
    or
    GC.Collect()
    the memory is not released.

    Many thanks

  2. #2
    Join Date
    May 2007
    Posts
    1,546

    Re: Why my dataset doesn't release memory!!

    This should help explain how a garbage collector works:

    http://en.wikipedia.org/wiki/Garbage...ter_science%29
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  3. #3
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Why my dataset doesn't release memory!!

    I see there are a lot of question about it ...
    ... and there's a lot of answers about it, like limiting your SQL query or use a DataReader instead or just leaving the GC alone because it's nothing to worry about.

    If you REALLY want to force a GC cycle do this outside the using block (after making sure nothing holds a reference to your data set i.e. don't set it as a source on a DataGrid, don't hold it in a member variable) :

    Code:
    GC.GetTotalMemory(true);
    but you shouldn't.

    If you need deterministic cleanup of memory use C++.

    Darwen.
    Last edited by darwen; August 29th, 2009 at 05:07 AM.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured