Commit ef974dc
committed
Fix memory leak with WeakMap + String objects
- Replace unbounded cache with WeakMap
- Return String objects instead of primitives
- String objects can be WeakMap keys and are GC'd automatically
- No eviction issues - entries only released when truly unreferenced
- Requires calling .valueOf() on final result before serialization
This approach is based on PR developit#43 but adapted for server-side usage.1 parent 0b9c0e2 commit ef974dc
2 files changed
Lines changed: 7 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 72 | | |
76 | 73 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
| |||
63 | 57 | | |
64 | 58 | | |
65 | 59 | | |
66 | | - | |
67 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
68 | 64 | | |
0 commit comments