lib/lightgbm/booster.rb in lightgbm-0.2.7 vs lib/lightgbm/booster.rb in lightgbm-0.3.0
- old
+ new
@@ -12,11 +12,11 @@
else
params ||= {}
set_verbosity(params)
check_result FFI.LGBM_BoosterCreate(train_set.handle_pointer, params_str(params), @handle)
end
- ObjectSpace.define_finalizer(self, self.class.finalize(handle_pointer))
+ ObjectSpace.define_finalizer(@handle, self.class.finalize(handle_pointer.to_i))
self.best_iteration = -1
# TODO get names when loaded from file
@name_valid_sets = []
@@ -177,12 +177,12 @@
finished = ::FFI::MemoryPointer.new(:int)
check_result FFI.LGBM_BoosterUpdateOneIter(handle_pointer, finished)
finished.read_int == 1
end
- def self.finalize(pointer)
+ def self.finalize(addr)
# must use proc instead of stabby lambda
- proc { FFI.LGBM_BoosterFree(pointer) }
+ proc { FFI.LGBM_BoosterFree(::FFI::Pointer.new(:pointer, addr)) }
end
private
def handle_pointer