Skip to content

Commit 63d2439

Browse files
committed
Removing module.parent and module.children to avoid memory leaks.
1 parent 7ca7d7d commit 63d2439

2 files changed

Lines changed: 3 additions & 12 deletions

File tree

doc/api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ in [Node.js](http://nodejs.org/api/globals.html):
1919
* [module.filename](http://nodejs.org/api/modules.html#modules_module_filename) and [module.id](http://nodejs.org/api/modules.html#modules_module_id)
2020
* [module.loaded](http://nodejs.org/api/modules.html#modules_module_loaded)
2121
* [module.require](http://nodejs.org/api/modules.html#modules_module_require_id)
22-
* [module.parent](http://nodejs.org/api/modules.html#modules_module_parent)
23-
* [module.children](http://nodejs.org/api/modules.html#modules_module_children)
2422
* [__filename](http://nodejs.org/api/globals.html#globals_filename)
2523
* [__dirname](http://nodejs.org/api/globals.html#globals_dirname)
2624

src/modules/context.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ var Module = function(context, filename) {
6161
this.require = bind1(context.moduleRequire, context, this);
6262
this.require.resolve = bind1(context.moduleResolve, context, this);
6363
this.require.cache = context.cache;
64-
this.parent = null;
65-
this.children = [];
64+
this.require.main = context.main;
6665
this.preloaded = false;
6766
this.loaded = false;
6867
this.exports = {};
@@ -83,7 +82,8 @@ var start = function(context) {
8382

8483
var main = config.main;
8584
actions = actions.thenSync(main ? function() {
86-
return context.execModuleCall(main);
85+
var res = context.main = context.execModuleCall(main);
86+
return res;
8787
} : function() {} /* if there is no main module, an empty parameter should be passed to onstart */ );
8888

8989
actions = actions.thenSync(config.onstart);
@@ -174,13 +174,6 @@ contextProto.modulePreload = function(module, parent) {
174174
return preloading;
175175
}
176176
var self = this;
177-
if (parent && parent.id != '.') {
178-
module.parent = parent;
179-
module.require.main = parent.require.main;
180-
parent.children.push(module);
181-
} else {
182-
module.require.main = module;
183-
}
184177
setModuleProperty(module, PROPERTY_PRELOADING_PARENTS, parent ? [parent] : []);
185178
return setModuleProperty(module, PROPERTY_PRELOADING, self.moduleLoadDefinition(module).thenSync(function() {
186179
return self.modulePreloadDependencies(module, getModuleProperty(module, PROPERTY_DEPENDENCIES));

0 commit comments

Comments
 (0)