Closed pprocacci closed 5 years ago
Also, I wanted to point out that a version stripped of mostly everything did NOT exhibit this problem.
unit module Testing;
use NativeCall;
sub library is export { return 'libncurses.so.5'; }
my $COLS; sub COLS is export { unless $COLS { $COLS := cglobal(&library, 'COLS', int32); } return $COLS; }
class WINDOW is export is repr('CPointer') { }
my $stdscr; sub stdscr is export { unless $stdscr { $stdscr = cglobal(&library, 'stdscr', WINDOW); } return $stdscr; }
sub initscr() returns WINDOW is native(&library) is export {*};
The problem stems from the library-exists function.
Leak: +++++++++++++++++++++++++++++++++ if library-exists('libncurses.so') { return "libncurses.so"; }
No Leak: +++++++++++++++++++++++++++++++++ return "libncurses.so";
Moving this off your plate. This isn't a problem with your module ...... most likely a moar vm issue.
COLS() - Not only uses a tremendous amount of cpu to return the number of columns, each iteration of the call consumes more and more memory until all memory is consumed and it crashes. I suspect LINES() does the same, but I haven't tested it.
root@FreeBSD11:~ # uname -sr FreeBSD 11.2-RELEASE
OR
root@host:~ % uname -sr Linux 4.13.0-46-generic
root@FreeBSD11:~ # perl6 --version This is Rakudo Star version 2018.06 built on MoarVM version 2018.06 implementing Perl 6.c.
I suspect this is a problem with moarvm, but figured I'd start here.
+++++++++++++++++++++++++++++++++++++++++++++++
!/usr/bin/env perl6
use NCurses;
sub MAIN() { my $win = initscr() or die("Failed to initialize ncurses\n"); loop { say COLS(); sleep(1); } delwin($win) if $win; endwin; }