c# - Is there a way to check if garbage collection was triggered while analyzing dump file through SOS.dll -
i analyzing .dmp file "outofmemory" exception. objects staying in memory long time, there command check if garbage collection triggered using sos.dll or sosex?
in comment mention
when @ dump, see particular object staying in generation 2 occupying 500+ mb, wanted check if garbage collection ran or not.
if have object in gen 2, garbage collection ran @ least 2 times, otherwise in gen 0.
now know it, it's obvious information not helpful. want know why remains in memory.
to find out reference keeps large object in memory, use sos command !gcroot
. when know that, review code find out such reference comes or should removed.
if there no reference more, object may freed , it's alive because no gen 2 garbage collection has occurred since. see this great answer on idisposable, discusses point of releasing large object.
in case, might ok call gc.collect()
after releasing reference. should not tamper garbage collection, if have such large object , know object no longer needed , gc.collect()
resolves oom exception, right thing do.
Comments
Post a Comment