.net memory leaks
-
top right of form. Looks like memory is leaking. Don't rememebr vb6 doing this. Many thanks.
-
top right of form. Looks like memory is leaking. Don't rememebr vb6 doing this. Many thanks.
My guess is that the memory usage hasn't grown enough to trigger the garbage collector. You could try calling Dispose() on the second window after it closes and see if that has any effect. You could also try "manually" invoking garbage collection after the second window closes (first setting any references to it to null).
-
top right of form. Looks like memory is leaking. Don't rememebr vb6 doing this. Many thanks.
Bret Stern wrote:
watch memory in task manager),
There's your first mistake. Task Manager is not showing you how much memory your application is using, but how much the .NET CLR has RESERVED for your application. Use the .NET Memory counters in PerfMon to find out how much memory your app is actually using. By reserved, I mean your application can free memory that it isn't using any more but that memory goes back the Managed Heap for future allocations. It will not be freed back to Windows unless the CLR deems that it doesn't need the memory or Windows starts to run low on memory and requests that the .NET CLR frees up whatever it can. The is a completely automatic process and the .NET Memory Manager does it's job very well. You do not need to worry about freeing up the memory yourself. Next, this depends on what you're using to show the second form. If you use the .ShowDialog() method on your form instance you MUST call Dispose() method on the form instance when you're done with the form. If you don't do this you WILL run into memory and handle issues, possibly running Windows out of resources. Oh, and do NOT call GC.Collect() unless you know exactly why you're doing it and understand completely the impacts on the GC. You can easily negatively impact the performance of your application by calling Collect unnecessarily.
A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak -
Bret Stern wrote:
watch memory in task manager),
There's your first mistake. Task Manager is not showing you how much memory your application is using, but how much the .NET CLR has RESERVED for your application. Use the .NET Memory counters in PerfMon to find out how much memory your app is actually using. By reserved, I mean your application can free memory that it isn't using any more but that memory goes back the Managed Heap for future allocations. It will not be freed back to Windows unless the CLR deems that it doesn't need the memory or Windows starts to run low on memory and requests that the .NET CLR frees up whatever it can. The is a completely automatic process and the .NET Memory Manager does it's job very well. You do not need to worry about freeing up the memory yourself. Next, this depends on what you're using to show the second form. If you use the .ShowDialog() method on your form instance you MUST call Dispose() method on the form instance when you're done with the form. If you don't do this you WILL run into memory and handle issues, possibly running Windows out of resources. Oh, and do NOT call GC.Collect() unless you know exactly why you're doing it and understand completely the impacts on the GC. You can easily negatively impact the performance of your application by calling Collect unnecessarily.
A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave KreskowiakNot use to the memory babysitting. Thanks for the explanations.
-
My guess is that the memory usage hasn't grown enough to trigger the garbage collector. You could try calling Dispose() on the second window after it closes and see if that has any effect. You could also try "manually" invoking garbage collection after the second window closes (first setting any references to it to null).
Thank you. Seem to remember something about garbage collection being automatic. The environment looks pretty slick. Should be lots of fun.