Click here to Skip to main content
15,076,130 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone,
i'm developing an application and I have some problem of memory leak so I tried to create another application with just one button and click event without code inside and when I make a click on that button the memory of the application grow up. Does anyone can explain me why ? or if you have some issue to resolve it?
Rohit Kumar Mumbai 19-Mar-13 7:36am
Seems its related to your PC Configuration Issue.. Doesnt look like memory Leak. Please try running same code on Another pc .
OriginalGriff 19-Mar-13 7:40am
From that little info? No idea.
Show us the code you are using the in click handler and we might be able to help...

I assume you are assuming this is a memory leak as Task Manager is showing the memory growing...?

TaskManager will show you the amount of memory reserved for your application, not the amount actually used. If reserved but not used memory is required by the system it will be reclaimed.

In other words, it's nothing to worry about - just make sure you are disposing of anything that is disposable (using 'using blocks' is the best way if it works in your scenario).
I don't think you have a memory leak issue. An increase in memory usage does not necessarily mean a memory leak. Each time you click on the button, there may be many memory allocations and disposes that occur that are not part of your code but are part of the .NET Framework itself. The .NET Framework has a garbage collector function that periodically frees memory after it has been disposed. There also may be memory allocations and deallocations in the Windows APIs that the .NET Framework uses.

See Garbage Collection[^].

Unless you can show that your PC runs out of memory after tens of thousands, hundreds of thousands or millions of button clicks, I'll continue to believe that you are just seeing the natural growth in memory usage inherent in the .NET Framework memory handling processes and Windows memory handling processes.
Maurizio1976 21-Mar-13 4:42am
thanks you for the answer,
Yesterday i found this program .Net MemProfiler, i tried to lauch the application and see belong what i get after snapshot:

Disposed instances (Show details) (Ignore...)
2 types have instances that have been disposed but not GCed.
Investigate the types below for more information.

System.Drawing.Graphics, WindowsFont

Undisposed instances (release resource) (Show details) (Ignore...)
3 types have instances that have been garbage collected without being properly disposed.
Investigate the types below for more information.

SafePEFileHandle, SafeTokenHandle, WindowsFont

Pinned instances (Show details) (Ignore...)
2 types have instances that are pinned in memory.
Investigate the types below for more information.

System.Object, System.Object[]

Undisposed instances (memory/resource utilization) (Show details) (Ignore...)
3 types have instances that have been garbage collected without being properly disposed.
Investigate the types below for more information.

System.IO.BinaryReader, UnmanagedMemoryStream, WindowsFormsSynchronizationContext

Duplicate instances (Show details) (Ignore...)
37 types have duplicate instances (228 sets, 39.918 duplicated bytes). Duplicate instances can cause unnecessary memory consumption.
Investigate the types below for more information.

ArrayList (6 sets, 14.888 duplicated bytes), System.String (142 sets, 9.848 duplicated bytes), SecurityElement (5 sets, 6.396 duplicated bytes), Hashtable (2 sets, 5.400 duplicated bytes), Hashtable.bucket[] (one set, 4.176 duplicated bytes), Hashtable.SyncHashtable (one set, 2.860 duplicated bytes), System.Object (one set, 1.812 duplicated bytes), ConfigurationValues (one set, 1.632 duplicated bytes), System.String[] (3 sets, 1.340 duplicated bytes), System.Object[] (6 sets, 928 duplicated bytes), (...)

Empty weak reference (Show details) (Ignore...)
The WeakReference type has instances that are no longer alive.
Investigate the WeakReference type for more information.


Large instances (Show details) (Ignore...)
One type has instances that are located in the large object heap.
Investigate the type below for more information.


Held duplicate instances (Show details) (Ignore...)
8 types have duplicate instances that are held by other duplicate instances (241 sets, 19.008 duplicated bytes).
Investigate the types below for more information.

System.Object[] (74 sets, 17.892 duplicated bytes), SecurityElement (64 sets, 14.936 duplicated bytes), ArrayList (76 sets, 14.420 duplicated bytes), StrongNameMembershipCondition (21 sets, 6.552 duplicated bytes), System.String (2 sets, 816 duplicated bytes), TokenBasedSet (2 sets, 192 duplicated bytes), NamedPermissionSet (one set, 48 duplicated bytes), SecurityPermission (one set, 24 duplicated bytes)

Note: I remember you that the application is composed of : Window form, button and one event click with empty code.

if someone know MemProfiler and tell me why all this instance have been detected: or the program Memprofiler works badly or there is something to do inside the form designer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900