An extension of Memwatch-next (https://www.npmjs.com/package/memwatch-next).
- Dynamic wrapping of HeapDiff calculation around existing module/object functions.
$ npm install git://github.com/agostone/agna-node-memwatch.git --save-dev
agna-node-memwatch uses the singleton pattern, meaning you'll always get the same instance.
var Memwatch = require('agna-node-memwatch');
var instance = Memwatch();or
var Memwatch = require('agna-node-memwatch');
var instance = new Memwatch();memwatch.wrapHeapDiff(<target>, <functionName>);Should be a valid javascript object.
Should be a string pointing to a valid function on target. Sub-property references are allowed.
For example: To wrap MyObject.SubObject.Function:
memwatch.wrapHeapDiff(MyObject, 'SubObject.Fuction');or
memwatch.wrapHeapDiff(MyObject, ['SubObject','Fuction']);For more possibilities check the path parameter here: https://lodash.com/docs#get
If you wish all functions of an object to be wrapped, simply use '*' for functionName.
var WrapAll = {
function1: function () {},
function2: function () {},
function3: function () {}
};
memwatch.wrapHeapDiff(WrapAll, '*');In the above example function1, function2 and function3 will get wrapped.
var WrapAll = {
all: {
function4: function () {},
function5: function () {},
function6: function () {}
}
};
memwatch.wrapHeapDiff(WrapAll, 'all.*');In the above example function4, function5 and function6 will get wrapped.
For more information on how anga-node-memwatch determines the functions to wrap, look here: https://lodash.com/docs#functions
memwatch.on(<eventName>, <callback>);Fired before heap difference calculation starts.
The callback method registered for this event should have two parameters. One receiving the target object, the other the functionName string.
function heapStartCallback(target, functionName) {
}Fired after heap difference calculation ends.
The callback method registered for this even should have three parameters. First one receiving the target object, second the functionName string and the third the calculation result object.
function heapEndCallback(target, functionName, diffResult) {
}Fired when a possible lead detection been made. For more information check the "Leak Detection" section here: https://www.npmjs.com/package/memwatch-next
Heap usage statistics event fired at V8 garbage collection. For more information check the "Heap Usage" section here: https://www.npmjs.com/package/memwatch-next
$ jasmine
$ jsdoc --verbose -c ./jsdoc/configuration.json MemWatch.js
- More sophisticated wildcarding. How about rexep? How about sub-property wildcarding?
- How about ES6ifying? =}
- rubberduck for wrapping? =}
agna-node-memwatch is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.