Skip to content

Implement pluggable memory management #225

@antonfirsov

Description

@antonfirsov

Problem

Solution

Implement a pluggable MemoryManager, make the default pooling memory manager configurable.

Update:
feature/memory-manager is the WIP branch for this refactor. It's having #431 merged. If anyone wishes to contribute, please file your PR-s against that branch. The tasks below are being updated according to the progress on that branch.

Tasks for beta-3

  • Refactor all raw ArrayPool and PixelDataPool usages to use Buffer and Buffer2D instead.
  • Buffer2D<T> should compose Buffer<T> (as IBuffer<T>) instead of inheriting it
  • Move the responsibility of providing Buffer<T> instances to a generic MemoryManager class. Refactor all new Buffer<T> and new Buffer2D<T> instantiations to call factory method on MemoryManager instead.
  • We need to cover all the encoders/decoders with proper regression tests before continuing the refactor work. (Working on this - would be filed as a separate PR)
  • Extensive test coverage for ArrayPoolMemoryManager
  • Allocations in DefaultPixelBlenders<TPixel> should use MemoryManager taken from the outside
  • Replace the legacy PixelArea<TPixel> class with BufferArea<T> + extensions methods working on BufferArea<TPIxel> and/or IBuffer2D<TPixel> using PixelOperations<TPixel>
  • Replace all most PixelAccessor<TPixel> usages with Buffer2D<T>. Drop the IBuffer2D<T> interface. - the full removal could be done later.
  • MemoryManager should construct IBuffer<T> and IManagedByteBuffer instead of Buffer<T>, codecs should use IManagedByteBuffer.Array
  • Based on user feedback, there also might be some strange, unexpected leaking when images are created/destroyed continously. Doing some load testing, identifying+understanding this behavior is inevitable!

Probably 1.0

  • Passing custom MemoryManager to codecs

Most likely post- 1.0:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions