c# - how to check & force garbage collector to collect the objects of same class which is previously created..? -
i created c# winform application load controls dynamically database specification.i using split container panel.my application load 2 window forms in panel1 "menuform" , panel2 "canvasform" .when clicked in "menuform's" menu object of "canvasform" created , placed in panel2 per click. application running fine. problem clicked on menu form number of canvas form's object created , garbage collector not collected , memory of project's process increases simultaneously can see in "task manager" of windows.how resolved issue?.
example : if started application , process memory show in windows task manager 17,572 k when clicked numbers of time in menu form selecting menu.task manager showing 18,972 k if using application continuously might caused memory overflow.
the garbage collector is, definition, non-deterministic. means can't directly control behaviours, nor intended so... doing mean .net runtime not automatically managing memory you. can make specific calls gc.collect() not recommended. .net framework free memory needed.
if you're having problems memory usage, need investigate , fix issues in code. if have lot of objects reaching gen 2, memory balloon takes longer collect. goal either not create new objects, or create short-lived objects collected in gen 0 or 1 (0 better 1 here). evaluate code , improve reduce issues.
on top of of this, , gets tricky, memory reported in task manager not memory used application, memory reserved application heuristics of .net runtime...
read more information: .net garbage collection
Comments
Post a Comment