Fix: Memory leak in resolveCache #81

Closed
s524797336 wants to merge 3 commits from master into master
s524797336 commented 2024-06-24 14:06:00 +02:00 (Migrated from github.com)

This pull request addresses two main issues:

  1. Memory Leak Fix: Utilizes WeakMap to resolve the memory leak issue in resolveCache.
  2. TypeScript Type Errors: Includes minor corrections to TypeScript type errors for improved code quality and consistency.
This pull request addresses two main issues: 1. Memory Leak Fix: Utilizes WeakMap to resolve the memory leak issue in `resolveCache`. 2. TypeScript Type Errors: Includes minor corrections to TypeScript type errors for improved code quality and consistency.
marijnh commented 2024-06-25 08:53:40 +02:00 (Migrated from github.com)

Did this (bounded) leak cause any practical issue for you, or is this more of theoretical fix?

Did this (bounded) leak cause any practical issue for you, or is this more of theoretical fix?
s524797336 commented 2024-06-25 10:45:34 +02:00 (Migrated from github.com)

Did this (bounded) leak cause any practical issue for you, or is this more of theoretical fix?

Yes, this leak did cause my problem. The cached doc contains nodeTypes and their schemas. When I declared them, I injected my own context. This context is widely used within closures. The cached data stored here is not garbage collected, and all closures containing the context are not garbage collected either. In my case, a lot of things were leaked.

> Did this (bounded) leak cause any practical issue for you, or is this more of theoretical fix? Yes, this leak did cause my problem. The cached doc contains nodeTypes and their schemas. When I declared them, I injected my own context. This context is widely used within closures. The cached data stored here is not garbage collected, and all closures containing the context are not garbage collected either. In my case, a lot of things were leaked.
marijnh commented 2024-06-25 12:04:26 +02:00 (Migrated from github.com)

Merged your type changes as cde085e345 , and applied an alternative patch for the cache issue — 54de8c0752 , which doesn't allow cached positions to accumulate endlessly for a given document.

Merged your type changes as cde085e345b6815c54af9c386feb73bce3ad41ee , and applied an alternative patch for the cache issue — 54de8c0752572f267cf27d5144f9df1c1987953f , which doesn't allow cached positions to accumulate endlessly for a given document.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-model!81
No description provided.