V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
imherer
V2EX  ›  Node.js

对象上挂载模块是否也占用内存

  •  
  •   imherer · 2017-09-26 14:27:52 +08:00 · 2390 views
    This topic created in 2918 days ago, the information mentioned may be changed or developed.

    假如我有一个 object 内容如下:

    room={
      id:"xxxx",
      mode:"xxxx",
      logic: require('logic_x.js')
      //..... 一些其他的属性  
    }
    

    这个 room 是保存在内存中的,logic 这个 key 的值所占的内存大小是logic_x.js 这个文件的物理内存大小吗?

    logic_x.js 文件内容大致如下(多个函数)

    const someTasks = {};
    exports.f1 = function(){};
    exports.f2 = function(){};
    exports.f3 = function(){};
    // .....
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Tools   ·   5070 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 07:44 · PVG 15:44 · LAX 00:44 · JFK 03:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.