Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak ? #87

Open
invpe opened this issue Oct 19, 2023 · 3 comments
Open

Memory leak ? #87

invpe opened this issue Oct 19, 2023 · 3 comments

Comments

@invpe
Copy link

invpe commented Oct 19, 2023

Run this simple script 10000 times and you'll end up eating your memory.

DEF TEST() 
PRINT "WHATEVER";
ENDDEF
PRINT "HELLO WORLD";

Runtime logs:

22:14:00.174 -> Exe /last.bas Tout: 10000ms Heap: 204564 <<
22:14:00.206 -> Exe Loaded /last.bas Tout: 10000ms Heap: 195084
22:14:00.206 -> Exe /last.bas Tout: 10000ms Heap: 204224 <<
22:14:00.237 -> Exe Loaded /last.bas Tout: 10000ms Heap: 194744
22:14:00.237 -> Exe /last.bas Tout: 10000ms Heap: 203884 <<
22:14:00.237 -> Exe Loaded /last.bas Tout: 10000ms Heap: 194408

... 

22:15:05.877 -> Exe Loaded /last.bas Tout: 10000ms Heap: 155952 
22:15:05.877 -> Exe /last.bas Tout: 10000ms Heap: 165012<<
22:15:05.909 -> Exe Loaded /last.bas Tout: 10000ms Heap: 155600
22:15:05.909 -> Exe /last.bas Tout: 10000ms Heap: 164672 <<
22:15:05.909 -> Exe Loaded /last.bas Tout: 10000ms Heap: 155268
22:15:05.941 -> Exe /last.bas Tout: 10000ms Heap: 164332 <<
22:15:05.941 -> Exe Loaded /last.bas Tout: 10000ms Heap: 154916

As soon as you remove the DEF - ENDDEF block, you're fine, see below:

REM DEF TEST()
REM PRINT "WHATEVER";
REM ENDDEF
PRINT "HELLO WORLD";

Runtime log:

22:39:52.603 -> Exe /last.bas Tout: 10000ms Heap: 228608
22:39:52.603 -> Exe Loaded /last.bas Tout: 10000ms Heap: 218596
22:39:52.603 -> HELLO WORLD
22:39:52.603 -> Exe /last.bas Tout: 10000ms Heap: 228508 <<<<<<<<
22:39:52.641 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.641 -> HELLO WORLD
22:39:52.641 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.666 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.666 -> HELLO WORLD
22:39:52.666 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.666 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.666 -> HELLO WORLD
22:39:52.699 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.699 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.699 -> HELLO WORLD
22:39:52.699 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.731 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.731 -> HELLO WORLD
22:39:52.731 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.731 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.764 -> HELLO WORLD
22:39:52.764 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.764 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.764 -> HELLO WORLD
22:39:52.764 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.796 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.796 -> HELLO WORLD
22:39:52.796 -> Exe /last.bas Tout: 10000ms Heap: 228508
22:39:52.828 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.828 -> HELLO WORLD
22:39:52.828 -> Exe /last.bas Tout: 10000ms Heap: 228508 <<<<<<<<
22:39:52.828 -> Exe Loaded /last.bas Tout: 10000ms Heap: 220832
22:39:52.828 -> HELLO WORLD
@invpe
Copy link
Author

invpe commented Oct 20, 2023

This happens when MB_ENABLE_LAMBDA is undefined / used.

MB_ENABLE_LAMBDA

Enabled by default. Compiles with lambda (anonymous function)
support if this macro is defined.

Steps to reproduce

in my_basic.h undefine MB_ENABLE_LAMBDA


// #ifndef MB_ENABLE_LAMBDA
// #	define MB_ENABLE_LAMBDA
// #endif /* MB_ENABLE_LAMBDA */

@blazer2k1
Copy link

So based on your test there's mem leak if lambda is disabled?

@invpe
Copy link
Author

invpe commented Oct 21, 2023

Correct,
when MB_ENABLE_LAMBDA is not defined and DEF used in the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants