-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose and run GC for nodejs to avoid memory intensive actions to run…
… in memory limit (#1826) Expose garbage collection so that it is explicitly available for use in actions
- Loading branch information
1 parent
aee7958
commit 5a7467a
Showing
3 changed files
with
34 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -75,4 +75,4 @@ xmlhttprequest@1.8.0 \ | |
yauzl@2.7.0 | ||
|
||
# See app.js | ||
CMD node app.js | ||
CMD node --expose-gc app.js |
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,13 @@ | ||
function eat(memoryMB) { | ||
var bytes = 1*1024*1024*memoryMB; | ||
var buffer = new Buffer.alloc(bytes, 'a'); | ||
buffer = null; | ||
console.log('done.'); | ||
} | ||
|
||
function main(msg) { | ||
console.log('helloEatMemory', 'memory ' + msg.payload + 'MB'); | ||
global.gc(); | ||
eat(msg.payload); | ||
return {msg: 'OK, buffer of size ' + msg.payload + ' MB has been filled.'}; | ||
} |
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