LB Booster
« Memory leak detection »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:33am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Memory leak detection  (Read 652 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Memory leak detection
« Thread started 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.
User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: Memory leak detection
« Reply #1 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?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Memory leak detection
« Reply #2 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls