getsentry / getsentry/sentry-javascript
Memory leak in Sentry.withScope
- Lingua principale
- TypeScript
- Stelle
- 8.7k
- Fork
- 1.8k
- Merge medio
- 1g 17h
- PR unite (30g)
- 515
Descrizione
### Is there an existing issue for this?
- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [x] I have reviewed the documentation https://docs.sentry.io/
- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
### How do you use Sentry?
Sentry Saas (sentry.io)
### Which SDK are you using?
@sentry/node
### SDK Version
10.25.0
### Framework Version
_No response_
### Link to Sentry event
_No response_
### Reproduction Example/SDK Setup
```js
import * as Sentry from "@sentry/node";
import v8 from "node:v8";
Sentry.init({ dsn: "" });
let count = 0;
function handle() {
gc?.();
const largeData = new Array(1000000).fill("hello");
Sentry.withScope((scope) => {
scope.setExtra("data", largeData);
Sentry.captureMessage("hello");
});
const heapData = v8.getHeapStatistics();
count++;
if (count % 20 === 0) {
console.log(`${heapData.total_heap_size}`);
}
}
console.log(Sentry.SDK_VERSION);
while (true) {
handle();
}
```
### Steps to Reproduce
Run the above script with `node --expose-gc`.
```
$ node --expose-gc script.mjs
```
### Expected Result
The logged value can fluctuate but should not go up.
### Actual Result
```
10.25.0
213172224
373407744
533643264
693878784
854114304
1014349824
1174585344
1334820864
1495056384
1655291904
1815527424
1975762944
2136260608
2296496128
2456993792
2617491456
2777726976
2938224640
3098460160
3258957824
3419193344
<--- Last few GCs --->
[39532:0xb83400000] 66593 ms: Mark-Compact 3298.9 (3337.5) -> 3298.9 (3337.5) MB, pooled: 0 MB, 289.38 / 0.00 ms (average mu = 0.006, current mu = 0.007) testing; GC in old space requested
[39532:0xb83400000] 67044 ms: Mark-Compact 3306.6 (3345.1) -> 3306.5 (3345.1) MB, pooled: 0 MB, 448.04 / 0.00 ms (average mu = 0.006, current mu = 0.005) testing; GC in old space requested
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
(and a bunch of other things)
```
### Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.