You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should exeprience something similar, the only difference will be the last GC trace that should be last GC trace that contains a bigger heap size.
192
+
You should experience something similar, the only difference should be that the last GC trace will contain a bigger heap size.
193
193
194
194
```bash
195
195
<--- Last few GCs --->
@@ -211,7 +211,7 @@ How do you assert whether too many garbage collections are happening or causing
211
211
212
212
## Fix the leak
213
213
214
-
Now let's fix the leak. Instead of using a object to store our entries we could use a file.
214
+
Now let's fix the leak. Instead of using an object to store our entries, we could use a file.
215
215
216
216
Let's modify our script a bit:
217
217
@@ -251,7 +251,7 @@ async function summary () {
251
251
})();
252
252
```
253
253
254
-
Using a `Set` to store data is not a bad practice at all, you should just care about the memory footprint of your program.
254
+
Using a `Set` to store data is not a bad practice at all; you should just care about the memory footprint of your program.
255
255
256
256
> Note: you can find the source code of this exercice in the [Node.js Diagnostics repository](https://github.com/nodejs/diagnostics/tree/main/documentation/memory/step3/exerice).
* the memory footprint doesn't exceed 25mb versus more than 130mb with the first script.
265
+
* Mark-sweep events appear less frequently
266
+
* the memory footprint doesn't exceed 25MB versus more than 130MB with the first script.
267
267
268
-
It makes a lot of sense as the new version put less pressure on the memory than the first one.
268
+
It makes a lot of sense as the new version puts less pressure on the memory than the first one.
269
269
270
-
**Takeway**: What do you think about improving this script? You probably see that the new version of the script is slow. What if we use a `Set` again and write its content into a file only when the memory reach a certain size?
270
+
**Takeaway**: What do you think about improving this script? You probably see that the new version of the script is slow. What if we use a `Set` again and write its content into a file only when the memory reaches a specific size?
271
271
272
272
> (`getheapstatistics`)[https://nodejs.org/dist/latest-v16.x/docs/api/v8.html#v8getheapstatistics] API could help you.
0 commit comments