OCDocker.Processing.GarbageCollection module

Shared garbage-collection helpers for Processing modules.

OCDocker.Processing.GarbageCollection.gc_collect_interval(total_items)[source]

Choose a GC interval based on workload size.

Small workloads keep eager collection behavior while larger batches collect periodically to reduce overhead.

Parameters:

total_items (int) – Total number of items to process, used to determine GC interval.

Returns:

Number of items to process before the next GC collection.

Return type:

int

OCDocker.Processing.GarbageCollection.collect_periodically(processed_items, interval, collector=None)[source]

Run gc.collect() at a fixed interval.

Parameters:
  • processed_items (int) – Number of items processed so far, used to determine if it’s time to collect.

  • interval (int) – Number of items to process before the next GC collection.

  • collector (Optional[Callable[[], int]], optional) – Custom GC collection function, by default None (uses gc.collect).

Return type:

None

OCDocker.Processing.GarbageCollection.pool_chunksize(total_items, workers, factor=4)[source]

Compute a practical chunksize for Pool.imap_unordered.

Parameters:
  • total_items (int) – Total number of work items.

  • workers (int) – Number of pool workers.

  • factor (int, optional) – Work distribution factor. Higher values produce smaller chunks. Default is 4.

Returns:

Chunksize value, always >= 1.

Return type:

int