Skip to content

Commit bae989e

Browse files
Merge pull request #38 from stephencookdev/feature/memory-leak#35
Fix memory leak in WrappedPlugin
2 parents 3242b35 + e697453 commit bae989e

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

WrappedPlugin/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
243243
return wrappedReturn;
244244
};
245245

246+
module.exports.clear = () => {
247+
wrappedObjs.length = 0;
248+
wrappedHooks.length = 0;
249+
};
250+
246251
module.exports.WrappedPlugin = class WrappedPlugin {
247252
constructor(plugin, pluginName, smp) {
248253
this._smp_plugin = plugin;

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require("path");
22
const fs = require("fs");
33
const chalk = require("chalk");
4-
const { WrappedPlugin } = require("./WrappedPlugin");
4+
const { WrappedPlugin, clear } = require("./WrappedPlugin");
55
const {
66
getModuleName,
77
getLoaderNames,
@@ -120,6 +120,7 @@ module.exports = class SpeedMeasurePlugin {
120120
this.addTimeEvent("misc", "compile", "start", { watch: false });
121121
});
122122
tap(compiler, "done", () => {
123+
clear();
123124
this.addTimeEvent("misc", "compile", "end", { fillLast: true });
124125

125126
const outputToFile = typeof this.options.outputTarget === "string";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "speed-measure-webpack-plugin",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Measure + analyse the speed of your webpack loaders and plugins",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)