Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Memory leaks if I do not call garbage collection at app start

$
0
0

The application has a class with a finalizer (CF).
CF refers to instances of class C1.
An instance of class C2 refers to an instance of class C1.
Finalizer of CF removes the reference from C2 toC1.

When the application starts, a large number of C2 objects are created. They are needed throughout the application executing.
Then the following cycles occur periodically:
1) A large number of CF and C1 objects are created.
2)
Links to CF objects are removed

After each cycle, CF objects are not unloaded from memory, their finalizers are not called.
The application crashes when it reaches memory usage about 3.37 Gb.
BUT! If I call

GC.Collect();

before starting the cycles, THERE IS NO THE MEMORY LEAK.
During cycles, the call ofGC.Collect(); has no effect.


If I don’t call code above
, JetBrains dotMemory Profiler shows that all theCF objects are accessible only from the f-reacheble queue.

This behavior is stable and reproducible.
Screenshots of 2 profiling sessions (with leak and without one) here.







  • Добавить в Словарь
    • Новый список слов для Английский -> Русский...
    • Создать новый список слов...
  • Копировать

Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>