Skip to content

Conversation

@Link512
Copy link

@Link512 Link512 commented Jul 6, 2021

This is related to this issue.

  • Add a Close method to make sure that at the end of the Cache object lifecycle, all memory allocated through the freelist is deallocated

@f41gh7 f41gh7 requested review from Copilot and f41gh7 July 27, 2025 12:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a memory leak issue in the freelist by implementing proper memory cleanup functionality. The changes introduce methods to reload cache data from files while reusing existing memory and to properly deallocate memory when the cache is no longer needed.

  • Add ReloadFromFile method to reset and reload cache without memory leaks
  • Add Close method to properly deallocate memory at end of cache lifecycle
  • Modify memory allocation tracking to enable proper cleanup via clearChunks

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
malloc_mmap.go Adds tracking of base memory chunks and implements clearChunks for proper memory deallocation
malloc_heap.go Adds no-op clearChunks implementation for heap-based allocation
file.go Modifies load function to accept existing cache for reuse and updates related functions
fastcache.go Implements ReloadFromFile and Close methods on the Cache struct

@Link512 Link512 requested a review from f41gh7 August 8, 2025 21:38
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.

3 participants