Divide and conquer large objects to work GC

In my work, we discuss various approaches to cleaning up a large amount of managed memory ~ 50-100 MB. There are two approaches in the table (read: two senior developers cannot agree) and without experience the rest of the team does not know which approach is more desirable, performance or maintainability.

The data collected is a lot of small items, ~ 30,000, which, in turn, contain other elements, all objects are managed. There are many references between these objects, including event handlers, but not external objects. We will call this large group of objects and links as a whole called blob.

Approach # 1: Make sure that all object references in the blob are disabled and let the GC handle blob and all connections.

Approach # 2: Embed IDisposable on these objects, then call dispose on these objects and set references to Nothing and remove the handlers.

The theory of the second approach is that larger, longer objects take longer to clear in the GC. Thus, by cutting large objects into smaller bite pieces, the garbage collector will process them faster, which improves productivity.

So, I think the main question is this: does large groups of interconnected objects break the optimization of data for garbage collection or is it better to combine them and rely on garbage collection algorithms for data processing for you?

, , , GC , .

:, , "blob" - , .

, . "" , GCed. , , .

+5
7

- , IDisposable .

, IDisposable . . , " " .

. "blob", , . - ( GC , ). .

, IDisposable , , . () , , , GC - .

, , , . GC - - , .

+9

. GC . null. IDisposable GC perf.

- , , , . , , "". : . .

, . , .

+3

IDisposable .

, (, ) , ( ). ; , , , , .

IDisposable , , , , , , , .

, IDisposable , . Dispose ; blob .

+2

Microsoft , Dispose , Finalize, , ( , GDI ..). , , ( ).

GC ( , , , ).

+1

№ 2: IDisposable .

...

, GC. , , .

, ; , ( ). ( ) /, "" . , , , - "", .

+1

, , , , . GC.

, , , , , . , , , :

  • blob , , , , , 2. , , blob , , , 0 1. , , , , , , GC , 2,
  • , blob , blob . , blob , . . , , , . , ( ), , .

, . .

0

All Articles