diff --git a/packages/react-native-nitro-modules/cpp/core/HybridObject.cpp b/packages/react-native-nitro-modules/cpp/core/HybridObject.cpp index fff63a53..3996c620 100644 --- a/packages/react-native-nitro-modules/cpp/core/HybridObject.cpp +++ b/packages/react-native-nitro-modules/cpp/core/HybridObject.cpp @@ -4,64 +4,11 @@ #include "HybridObject.hpp" #include "JSIConverter.hpp" -#include "NitroLogger.hpp" - -#define LOG_MEMORY_ALLOCATIONS false namespace margelo::nitro { -#if LOG_MEMORY_ALLOCATIONS -static std::mutex _instanceCounterMutex; -static std::unordered_map _aliveInstances; -static std::unordered_map _instanceIds; - -static uint32_t incrementAliveInstancesAndGet(const char* name) { - std::unique_lock lock(_instanceCounterMutex); - return ++_aliveInstances[name]; -} - -static uint32_t decrementAliveInstancesAndGet(const char* name) { - std::unique_lock lock(_instanceCounterMutex); - return --_aliveInstances[name]; -} - -static uint32_t getTotalAliveInstances() { - std::unique_lock lock(_instanceCounterMutex); - uint32_t total = 0; - for (const auto& iter : _aliveInstances) { - total += iter.second; - } - return total; -} - -static int getId(const char* name) { - std::unique_lock lock(_instanceCounterMutex); - if (_instanceIds.find(name) == _instanceIds.end()) { - _instanceIds.insert({name, 1}); - } - auto iterator = _instanceIds.find(name); - return iterator->second++; -} -#endif - -HybridObject::HybridObject(const char* name) : HybridObjectPrototype(), _name(name) { -#if LOG_MEMORY_ALLOCATIONS - _instanceId = getId(name); - uint32_t alive = incrementAliveInstancesAndGet(_name); - uint32_t totalObjects = getTotalAliveInstances(); - Logger::log(LogLevel::Info, TAG, "(MEMORY) ✅ Creating %s (#%i)... (Total %s(s): %i | Total HybridObjects: %i)", _name, _instanceId, - _name, alive, totalObjects); -#endif -} - -HybridObject::~HybridObject() { -#if LOG_MEMORY_ALLOCATIONS - uint32_t alive = decrementAliveInstancesAndGet(_name); - uint32_t totalObjects = getTotalAliveInstances(); - Logger::log(LogLevel::Info, TAG, "(MEMORY) ❌ Deleting %s (#%i)... (Total %s(s): %i | Total HybridObjects: %i) ", _name, _instanceId, - _name, alive, totalObjects); -#endif -} +HybridObject::HybridObject(const char* name) : HybridObjectPrototype(), _name(name) {} +HybridObject::~HybridObject() {} std::string HybridObject::toString() { return "[HybridObject " + std::string(_name) + "]"; diff --git a/packages/react-native-nitro-modules/cpp/core/HybridObject.hpp b/packages/react-native-nitro-modules/cpp/core/HybridObject.hpp index 1158253e..132f8e80 100644 --- a/packages/react-native-nitro-modules/cpp/core/HybridObject.hpp +++ b/packages/react-native-nitro-modules/cpp/core/HybridObject.hpp @@ -136,7 +136,6 @@ class HybridObject : public virtual jsi::NativeState, public HybridObjectPrototy private: static constexpr auto TAG = "HybridObject"; const char* _name = TAG; - int _instanceId = 1; std::unordered_map> _objectCache; };