docstr: ...Test brute force method in order to see if we have a memory leak
  during typemap out
docstr_tok: ["...","Test","brute","force","method","in","order","to","see","if","we","have","a","memory","leak","during","typemap","out"]
code: def test_s_sparse_array2d_memory_leaks(self):
      """...Test brute force method in order to see if we have a memory leak
      during typemap out
      """
      import os
  
      try:
          import psutil
      except ImportError:
          print(
              "Without psutils we cannot ensure we have no memory leaks"
          )
          return
  
      def get_memory_used():
          """Returns memory used by current process"""
          process = psutil.Process(os.getpid())
          return process.memory_info()[0]
  
      cereal_file = "sparse.gen.cereal"
      try:
          n_rows = int(1e3)
          n_cols = int(1e2)
          s_spar = int((n_rows * n_cols) * 0.3)
  
          data_size = s_spar * 8
          # The size in memory of an array of ``size`` doubles
          bytes_size = (data_size * 2) + ((n_rows + 1) * 8)
  
          sparsearray_double = scipy.sparse.rand(
              n_rows, n_cols, 0.3, format="csr", dtype=np.float64
          )
  
          tick_double_sparse2d_to_file(cereal_file, sparsearray_double)
  
          initial_memory = get_memory_used()
          a = tick_double_sparse2d_from_file(cereal_file)
          first_filled_memory = get_memory_used()
  
          # Check that new memory is of the correct order (10%)
          self.assertAlmostEqual(
              first_filled_memory - initial_memory,
              bytes_size,
              delta=1.1 * bytes_size,
          )
  
          del a
          for i in range(10):
              # Check memory is not increasing
              gc.collect()
              filled_memory = get_memory_used()
              self.assertAlmostEqual(
                  filled_memory, initial_memory, delta=1.1 * bytes_size
              )
  
              X = tick_double_sparse2d_from_file(cereal_file)
              del X
  
          gc.collect()
  
          end = get_memory_used()
          self.assertAlmostEqual(
              end, initial_memory, delta=1.1 * bytes_size
          )
  
      finally:
          if os.path.exists(cereal_file):
              os.remove(cereal_file)
  
imports: import gc
  import unittest
  import weakref
  import numpy
  import scipy
  from scipy.sparse import csr_matrix
  from tick.array.build.array import tick_double_sparse2d_from_file
  from tick.array.build.array import tick_double_sparse2d_to_file
  from tick.array_test.build import array_test
label_desc: Use image node_id 8 for calling the Test obj's underlying member method code with example usage: obj.test_s_sparse_array2d_memory_leaks() and returns: process