-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix memory leaks, includes test to make sure fix is working
- Loading branch information
Showing
7 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,8 @@ node_js: | |
- '4' | ||
- '5' | ||
- '6' | ||
- '7' | ||
- '8' | ||
- '9' | ||
- '10' | ||
- '11' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var importFresh = require('import-fresh'); | ||
var t = require('tap') | ||
|
||
t.test('no memory leak when loading multiple times', function(t) { | ||
t.plan(1); | ||
importFresh('../') | ||
const mbUsedBefore = process.memoryUsage().heapUsed / 1024 ** 2; | ||
// simulate project with 4000 tests | ||
var i = 0; | ||
function importFreshGracefulFs() { | ||
importFresh('../'); | ||
if (i < 4000) { | ||
i++; | ||
process.nextTick(() => importFreshGracefulFs()); | ||
} else { | ||
global.gc(); | ||
const mbUsedAfter = process.memoryUsage().heapUsed / 1024 ** 2; | ||
// We expect less than a 2 MB difference | ||
const memoryUsageMB = Math.round(mbUsedAfter - mbUsedBefore); | ||
t.ok(memoryUsageMB < 2, 'We expect less than 2MB difference, but ' + memoryUsageMB + 'MB is still claimed.'); | ||
t.end(); | ||
} | ||
} | ||
importFreshGracefulFs(); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters