Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 14, 2025

Summary

Implements the requested VirtualResizableDirectMemory class that uses virtual memory APIs instead of heap allocation like the existing HeapResizableDirectMemory class.

Key Features

Cross-platform virtual memory allocation:

  • Windows: Uses VirtualAlloc/VirtualFree APIs
  • Unix-like systems (Linux, macOS): Uses mmap/munmap APIs
  • Linux optimization: Uses mremap for efficient memory resizing when available

Full ResizableDirectMemoryBase compatibility:

  • Implements all required abstract methods
  • Maintains same interface as other memory implementations
  • Proper memory zeroing and cleanup

Comprehensive testing:

  • Tests memory allocation, resizing, and deallocation
  • Verifies data preservation during resize operations
  • Tests initial memory zeroing behavior
  • Validates capacity management

Implementation Details

The implementation includes proper P/Invoke declarations for native APIs and handles platform-specific differences. Memory tracking ensures proper cleanup with platform-appropriate APIs.

Package Updates

  • Version bumped to 0.5.0 (minor version for new feature)
  • Added VirtualResizableDirectMemory to package tags
  • Updated release notes

Test Results

All tests pass successfully:

  • 7 tests total: 7 passed, 0 failed
  • Tests cover allocation, resizing, data preservation, and capacity management

Resolves

Closes #11

🤖 Generated with Claude Code

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

Issue: #11
@konard konard self-assigned this Sep 14, 2025
Implements cross-platform virtual memory allocation for resizable direct memory:
- Uses VirtualAlloc/VirtualFree on Windows
- Uses mmap/munmap on Unix-like systems (Linux, macOS)
- Optimizes Linux resizing with mremap when available
- Includes comprehensive unit tests covering allocation, resizing, and data preservation
- Updates version to 0.5.0 and package metadata

Resolves issue #11 requesting virtual memory API implementation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Add VirtualResizableDirectMemory, that uses virtual memory API Add VirtualResizableDirectMemory class using virtual memory API Sep 14, 2025
@konard konard marked this pull request as ready for review September 14, 2025 10:18
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 VirtualResizableDirectMemory, that uses virtual memory API

2 participants