Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 13, 2025

Summary

This PR adds non-resizable (fixed-size) memory implementations to complement the existing resizable memory implementations. These are particularly useful for scenarios where you want to allocate all available resources at once (e.g., all RAM or a whole drive) and avoid time wasted on reallocations.

New Components Added:

  • IFixedDirectMemory - Interface for fixed-size direct memory access that extends IDirectMemory
  • FixedDirectMemoryBase - Abstract base class providing common functionality for fixed memory implementations
  • HeapFixedDirectMemory - Fixed-size memory allocation using unmanaged heap memory
  • FileMappedFixedDirectMemory - Fixed-size memory allocation using memory-mapped files
  • Comprehensive unit tests - Full test coverage for all new implementations

Key Features:

  • Performance optimized - No resize overhead since size is fixed at allocation
  • Resource allocation - Ideal for allocating all available RAM or storage at once
  • Consistent API - Follows the same patterns as existing resizable memory implementations
  • Memory safety - Proper disposal and error handling
  • Cross-platform - Works on all platforms supported by .NET

Implementation Details:

  • All implementations properly handle minimum capacity enforcement
  • Memory is zero-initialized for heap allocations
  • File-mapped memory supports persistence across application restarts
  • Proper disposal prevents memory leaks
  • Thread-safe disposal using atomic operations

Test Coverage:

  • Constructor validation and capacity enforcement
  • Memory allocation and deallocation
  • Read/write operations
  • Persistence testing for file-mapped memory
  • Disposal and error condition testing

Resolves #48

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #48
@konard konard self-assigned this Sep 13, 2025
This implementation adds fixed-size (non-resizable) memory blocks to complement the existing resizable memory implementations. These are useful for allocating all available resources at once and avoiding time spent on reallocations.

Features:
- IFixedDirectMemory interface for fixed-size direct memory access
- FixedDirectMemoryBase abstract base class
- HeapFixedDirectMemory for fixed heap allocations
- FileMappedFixedDirectMemory for fixed file-mapped memory
- Comprehensive unit tests for all implementations

The implementations follow the same patterns as existing resizable memory but are optimized for scenarios where the size is known upfront and will not change.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Add non-resizable memory implementations Add non-resizable memory implementations Sep 13, 2025
@konard konard marked this pull request as ready for review September 13, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add non-resizable memory implementations

2 participants