What diagnostic tools are available for Node.js applications?

我怕爱的太早我们不能终老 提交于 2019-12-24 03:14:10

问题


There are many tools out there, which diagnostics tools are good for diagnostic memory leak issues for node.js applications?


回答1:


Yes, IDDE is a powerful tool not only for memory leak detection, but for a wide variety of problem determination of Node.js misbehaviors, including crashes and hangs.

Here is the link for overview, installation, and what is new information: https://www.ibm.com/developerworks/java/jdk/tools/idde

  1. I would start with nodeoverview command. Note that every command starts with a bang (!) and every command is entered with a control (ctrl+enter) for reasons.

!nodeoverview {

Heap and Garbage Collection

Memory allocator, used: 981 MB, available: 482 MB GC Count: 144

This shows up the occupancy of the heap.

  1. Then, use jsmeminfo to figure out the predominent resident objects in the heap.

    !jsmeminfo {

    Memory allocator, used: 981 MB, available: 482 MB Total Heap Objects: 21559924

    Largest 5 heap objects Type Size (bytes) More information


    0x00000000de06d319 FIXED_ARRAY_TYPE 131112 !array 0x00000000de06d319 0x00000000de0ac6d9 FIXED_ARRAY_TYPE 98360 !array 0x00000000de0ac6d9 0x00000000e90e2f09 ASCII_STRING_TYPE 48152 !string 0x00000000e90e2f09 0x00000000e9035099 ASCII_STRING_TYPE 48088 !string 0x00000000e9035099 0x00000000e9004101 ASCII_STRING_TYPE 40936 !string 0x00000000e9004101

    Most Frequent 5 object types Frequency


    JS_OBJECT_TYPE 15371393 FIXED_ARRAY_TYPE 6175379 ASCII_INTERNALIZED_STRING_TYPE 3476 BYTE_ARRAY_TYPE 1572 JS_FUNCTION_TYPE 1434

    }

  2. Review the application based on this information and see they holding up the memory as shown is justified or not.

  3. If you want to 'dissect' the objects further to see the content, use object expansion commands such as !jsobject or !array:

    !array 0x00000000de06d319 {

    Array type : FIXED_ARRAY_TYPE Len : 16387 Showing first 100 elements only 0 : 0xd9400000000 (SMI) 1 : 0x3fe00000000 (SMI) 2 : 0x400000000000 (SMI) 3 : 0x9a1103d1 (ASCII_INTERNALIZED_STRING_TYPE : !print 0x000000009A1103D1 ) 4 : 0x9a1042a9 (ASCII_INTERNALIZED_STRING_TYPE : !print 0x000000009A1042A9 ) ... }

  4. If you want to 'segregate' the entire heap into sections based on object's internal types, user jsgroupobjects. This is more useful when you have multiple dumps taken at different time intervals, and want to compare which objects grew over time.

    !jsgroupobjects {

    Representative Object Address Object Type Num Objects Constructor Num Properties Properties


    !jsobject 0x00000000c8244fd1 JS_OBJECT_TYPE 6133503 Object 0
    !jsobject 0x00000000c8004161 JS_OBJECT_TYPE 6133499 Database 0
    !jsobject 0x00000000c8004101 JS_OBJECT_TYPE 3066750 MyRecord 0
    !jsobject 0x00000000c869b111 JS_OBJECT_TYPE 37302 Object 0
    !jsobject 0x00000000de05b959 JS_FUNCTION_TYPE 542 0
    !jsobject 0x00000000de04bcc1 JS_FUNCTION_TYPE 267 0
    !jsobject 0x00000000de04aa09 JS_FUNCTION_TYPE 251 0
    !jsobject 0x00000000de04a911 JS_FUNCTION_TYPE 227 0
    !jsobject 0x00000000de0a48c9 JS_ARRAY_TYPE 190 Array 0
    !jsobject 0x00000000de04a7e9 JS_FUNCTION_TYPE 102 0
    !jsobject 0x00000000de04e379 JS_ARRAY_TYPE 34 Array 0
    !jsobject 0x00000000de050db1 JS_OBJECT_TYPE 30 Object 0
    !jsobject 0x00000000c2938151 JS_REGEXP_TYPE 18 RegExp 0
    !jsobject 0x00000000c2955a11 JS_OBJECT_TYPE 15 NativeModule 0
    !jsobject 0x00000000c2944519 JS_OBJECT_TYPE 11 Object 0
    !jsobject 0x00003abc617bee71 JS_OBJECT_TYPE 102 CallSite 3 receiver, fun, pos

  5. If you want to examine a single object, do jsobject on the object address.

    !jsobject 0x00003abc617bee71 {

    Object has fast properties Number of descriptors : 3

    Name Value More Information


    receiver 0x0000251abe506c91
    fun 0x00003abc617bb241 pos 0x00001dfd00000000 SMI = 0x1dfd

    }




回答2:


module https://www.npmjs.com/package/appmetrics but it is more for monitoring and profiling. You can check it out, it is useful.



来源:https://stackoverflow.com/questions/30834656/what-diagnostic-tools-are-available-for-node-js-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!