Skip to content

Memory leak with optimize skopt #883

@diegolovison

Description

@diegolovison

Expected Behavior

No memory leak

Actual Behavior

A huge amount of memory that prevents the optimization process

Steps to Reproduce

Create the folling class

  class MyMemoryDumper(object):
      def __init__(self):
          self.every = 2000
          self.count = 0

      def __call__(self, res):
          if self.count != 0 and self.count % self.every == 0:
              obj_list = gc.get_objects()
              new_values = {}
              for obj in obj_list:
                  size_obj = sys.getsizeof(obj)
                  new_values[str(obj)] = size_obj
              new_values = sorted(new_values)
              print('end')
          self.count += 1

Add it to base_estimator

forest_minimize( 
      base_estimator=ExtraTreesRegressor(n_estimators=20, min_samples_leaf=2),
      callback=[DeltaXStopper(9e-7), MyMemoryDumper()],

Additional info

Add a breakpoint in MyMemoryDumper::print('end'). There are a lot of DataFrames from self.run

Backtesting==0.3.3
OS: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions