[gjs: 12/15] module: Add memory counters



commit 8055d94eb0b6162b9b66dd79488e62d6b97e231a
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Dec 21 10:51:22 2018 -0700

    module: Add memory counters
    
    This adds memory counters for module objects, similar to all the other
    JS objects that have their own private structures.

 gjs/mem-private.h | 1 +
 gjs/mem.cpp       | 2 ++
 gjs/module.cpp    | 3 +++
 3 files changed, 6 insertions(+)
---
diff --git a/gjs/mem-private.h b/gjs/mem-private.h
index df223af0..32212be9 100644
--- a/gjs/mem-private.h
+++ b/gjs/mem-private.h
@@ -42,6 +42,7 @@ GJS_DECLARE_COUNTER(fundamental)
 GJS_DECLARE_COUNTER(gerror)
 GJS_DECLARE_COUNTER(importer)
 GJS_DECLARE_COUNTER(interface)
+GJS_DECLARE_COUNTER(module)
 GJS_DECLARE_COUNTER(ns)
 GJS_DECLARE_COUNTER(object_instance)
 GJS_DECLARE_COUNTER(object_prototype)
diff --git a/gjs/mem.cpp b/gjs/mem.cpp
index c973397c..6eafdd1a 100644
--- a/gjs/mem.cpp
+++ b/gjs/mem.cpp
@@ -42,6 +42,7 @@ GJS_DEFINE_COUNTER(fundamental)
 GJS_DEFINE_COUNTER(gerror)
 GJS_DEFINE_COUNTER(importer)
 GJS_DEFINE_COUNTER(interface)
+GJS_DEFINE_COUNTER(module)
 GJS_DEFINE_COUNTER(ns)
 GJS_DEFINE_COUNTER(object_instance)
 GJS_DEFINE_COUNTER(object_prototype)
@@ -62,6 +63,7 @@ static GjsMemCounter* counters[] = {
     GJS_LIST_COUNTER(gerror),
     GJS_LIST_COUNTER(importer),
     GJS_LIST_COUNTER(interface),
+    GJS_LIST_COUNTER(module),
     GJS_LIST_COUNTER(ns),
     GJS_LIST_COUNTER(object_instance),
     GJS_LIST_COUNTER(object_prototype),
diff --git a/gjs/module.cpp b/gjs/module.cpp
index ff180f37..258d9b1e 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -27,6 +27,7 @@
 #include <gio/gio.h>
 
 #include "gjs/context-private.h"
+#include "gjs/mem-private.h"
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
 #include "module.h"
@@ -38,11 +39,13 @@ class GjsModule {
     GjsModule(const char *name)
     {
         m_name = g_strdup(name);
+        GJS_INC_COUNTER(module);
     }
 
     ~GjsModule()
     {
         g_free(m_name);
+        GJS_DEC_COUNTER(module);
     }
 
     /* Private data accessors */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]