Hey there kojix2,
I am currently improving (rewriting) the widgets project. One part of it
is libui-ng, via ruby, and I am starting with the libui component here,
as it is the simplest.
In some of my code I run into this problem:
** (ruby:74487): CRITICAL **: 10:29:40.948: [libui]
../unix/alloc.c:42:uiprivUninitAlloc() You have a bug: Some
data was leaked; either you left a uiControl lying around
or there's a bug in libui itself. Leaked data:
0x56330e273110 uiWindow
Trace/breakpoint trap (core dumped) ruby 027_notification_functionality_example.rb
I ran into this because I accidentally created more widgets than I need
to. I store them in a Hash via their object-id, such as:
{112 => [#<Fiddle::Pointer:0x000056330e1f0950 ptr=0x000056330e273120 size=0 free=0x0000000000000000>, :window],
120 => [#<Fiddle::Pointer:0x000056330dcc0f80 ptr=0x000056330e39a0b0 size=0 free=0x0000000000000000>, :window]}
So I had two main windows here. Ok, I found the problem, now I have
only one window, but ... this got me thinking. I actually keep that
reference in the Hash, so I could de-allocate all of those entries
when LibUI termnates. For instance, if there is a method we could
call on LibUI that accepts a Hash, then it could clean up all those
entries. I can also pass in an Array to this, e. g. Fiddle::Pointers
being there.
I don't know if this is really needed though. Very few people run
into this I guess. Either way I wanted to suggest this, because
sometimes debugging is not trivial, and if I'd have a function
such as:
LibUI.free
LibUI.deallocate
LibUI.de_allocate
LibUI.uninit
That actually access an Array of fiddle-pointers then I could
"manually" clean this up. I guess we have LibUI.uninit() but
this seems to be for something else. (By the way, calling
LibUI.uninit() from within irb crashes irb. Interestingly
calling LibUI.uninit([]) does not crash it but leads to:
ffi.rb:28:in 'Fiddle::Function#call': wrong number of arguments (given 1,)
Hey there kojix2,
I am currently improving (rewriting) the widgets project. One part of it
is libui-ng, via ruby, and I am starting with the libui component here,
as it is the simplest.
In some of my code I run into this problem:
I ran into this because I accidentally created more widgets than I need
to. I store them in a Hash via their object-id, such as:
So I had two main windows here. Ok, I found the problem, now I have
only one window, but ... this got me thinking. I actually keep that
reference in the Hash, so I could de-allocate all of those entries
when LibUI termnates. For instance, if there is a method we could
call on LibUI that accepts a Hash, then it could clean up all those
entries. I can also pass in an Array to this, e. g. Fiddle::Pointers
being there.
I don't know if this is really needed though. Very few people run
into this I guess. Either way I wanted to suggest this, because
sometimes debugging is not trivial, and if I'd have a function
such as:
LibUI.free
LibUI.deallocate
LibUI.de_allocate
LibUI.uninit
That actually access an Array of fiddle-pointers then I could
"manually" clean this up. I guess we have LibUI.uninit() but
this seems to be for something else. (By the way, calling
LibUI.uninit() from within irb crashes irb. Interestingly
calling LibUI.uninit([]) does not crash it but leads to:
ffi.rb:28:in 'Fiddle::Function#call': wrong number of arguments (given 1,)