octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #65669] Memory Leak when Using Cell


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #65669] Memory Leak when Using Cell
Date: Thu, 2 May 2024 11:28:00 -0400 (EDT)

Follow-up Comment #15, bug #65669 (group octave):

This debugging patch to trace the allocations and deallocations:


diff -r e17b6b7de50f liboctave/array/Array.h
--- a/liboctave/array/Array.h   Wed May 01 17:18:37 2024 -0400
+++ b/liboctave/array/Array.h   Thu May 02 11:23:34 2024 -0400
@@ -33,6 +33,7 @@
 
 #include <algorithm>
 #include <iosfwd>
+#include <iostream>
 #include <string>
 
 #include "Array-fwd.h"
@@ -195,6 +196,7 @@ protected:
 
     pointer allocate (size_t len)
     {
+      std::cout << "Calling allocate() with len = " << len << '\n';
       pointer data = Alloc_traits::allocate (*this, len);
       for (size_t i = 0; i < len; i++)
         T_Alloc_traits::construct (*this, data+i);
@@ -203,6 +205,7 @@ protected:
 
     void deallocate (pointer data, size_t len)
     {
+      std::cout << "Calling deallocate() with data = " << &(*data) << " len =
" << len << '\n';
       for (size_t i = 0; i < len; i++)
         T_Alloc_traits::destroy (*this, data+i);
       Alloc_traits::deallocate (*this, data, len);


followed by a bunch of manual reviewing and cancellations shows that there is
exactly one extra "allocate" message without a corresponding "deallocate" (per
element) when called with num2cell. I tried it with "A = 1" and then "B =
num2cell (A)".

Have to dig deeper to see whether an extra copy is being made or whether a
deallocation is being missed.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65669>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]