LB Booster
IDE and Compiler >> Debugger >> Memory leak detection
http://lbb.conforums.com/index.cgi?board=debugger&action=display&num=1420810477

Memory leak detection
Post by Richard Russell on Jan 9th, 2015, 12:34pm

It's not difficult to cause a memory leak in Liberty BASIC, typically this will happen if you jump out of a loop with GOTO rather than EXIT. This is an insidious fault, because your program may continue to run for minutes or hours or even longer, and then fail without warning when all the free memory is used up.

To help diagnose this problem I plan to enhance the LBB debugger so that it displays the current heap and stack usage. If either value increases inexorably as your program runs, it indicates a probable leak.

Richard.
Re: Memory leak detection
Post by Jack Kelly on Feb 14th, 2015, 06:55am

Can jumping out of an error handler with a goto rather than a resume cause a memory leak or another downside?
Re: Memory leak detection
Post by Richard Russell on Feb 14th, 2015, 07:16am

on Feb 14th, 2015, 06:55am, Jack Kelly wrote:
Can jumping out of an error handler with a goto rather than a resume cause a memory leak or another downside?

It's possible, but not very likely. If you use an ON ERROR GOTO in a subroutine, function or loop (FOR, WHILE, DO) it is automatically cancelled (and the memory it used freed) on exit.

So the only circumstance when a memory leak could result is if the ON ERROR GOTO is used in the 'lowest level' of your program, when you aren't in a function or loop. In that case you should explicitly cancel the error trapping using:

Code:
    ON ERROR GOTO 0 

Of course if jumping out of the error handler also means you have jumped out of a loop then certainly there will be a memory leak, but that's not directly related to the error trapping.

The current version of LBB (2.86) displays the heap and stack usage in the debugger, so if you are worried about the possibility of a memory leak from this cause in your own program(s) you can check it.

Richard.