|
-
August 24th, 2009, 03:12 AM
#3
Re: free memory allocated by datatable
The using statement maybe used to 'force' the garbage collector to step in and tidy memory immediately.
That's not quite right. The using statement is just a way to release *certain kinds* of resources immediately without having to wait for the GC. Examples include sockets and file handles. If you forget to close these yourself, the .NET garbage collector will eventually run and will eventually close the handles for you, but this provides a way for you to deterministically release those (limited) resources.
Calling Dispose (and using the 'using' pattern), does not make the GC do anything. It's completely separate to the GC. As for the original question, the memory is 'released' as soon as you don't have any live references to it anymore. Whenever the GC runs next it'll be collected. Your job is done.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|