diff --git a/src/node_mem.h b/src/node_mem.h
index 0d3388ad4766bb..f8cdc20848f82e 100644
--- a/src/node_mem.h
+++ b/src/node_mem.h
@@ -13,8 +13,12 @@ namespace mem {
 // use different struct names. To allow for code re-use,
 // the NgLibMemoryManager template class can be used for both.
 
+struct NgLibMemoryManagerBase {
+  virtual void StopTrackingMemory(void* ptr) = 0;
+};
+
 template <typename Class, typename AllocatorStructName>
-class NgLibMemoryManager {
+class NgLibMemoryManager : public NgLibMemoryManagerBase {
  public:
   // Class needs to provide these methods:
   // void CheckAllocatedSize(size_t previous_size) const;
@@ -24,7 +28,7 @@ class NgLibMemoryManager {
 
   AllocatorStructName MakeAllocator();
 
-  void StopTrackingMemory(void* ptr);
+  void StopTrackingMemory(void* ptr) override;
 
  private:
   static void* ReallocImpl(void* ptr, size_t size, void* user_data);