[TIB] Re: Question


[Prev][Next][Index][Thread]

[TIB] Re: Question




Sounds like you have done your homework, well your right about the
92plus I have one and have done extensive testing on the loops and
things in my battle sim game I am working on. And there is no memory
leak, but I had that problem on the 83 plus I have. So that was
fixed...thank god too cause I use loops a heck of a lot in that program.

-----Original Message-----
From: ti-basic-bounce@lists.ticalc.org
[mailto:ti-basic-bounce@lists.ticalc.org] On Behalf Of Travis Evans
Sent: Saturday, November 09, 2002 1:39 PM
To: ti-basic@lists.ticalc.org
Subject: [TIB] Re: Question



From: <robvanwijk@gmx.net>
> This, however, DOES leak memory (I'm going to assume
> it's two bytes for every Repeat/Goto pair, but I wouldn't
> know how to verify this):
>
> Lbl A
> Repeat 1
> Goto A

I think the biggest cause for memory leaks in BASIC programs are code
like
the following:

  :Lbl A
  :If [some condition] Then
  :   [some code here]
  :Goto B
  :End

I used to have that problem with my programs especially on my old TI-85
before I discovered the cause. The programs would slow down gradually
and
eventually give the memory error, and I never could figure out why.

It actually said in the manual in the error message appendix that this
could
cause this, but I thought the manual meant it would happen immediately
when
it encounters a Goto inside a loop, but it doesn't; the loop must be
executed several times. So I never had any problems and thought it was
okay
to use a Goto inside a loop as long as it was the last command. That's
why
it took me so long to figure it out.

But actually, you don't want Gotos inside loops. I'm not sure if the
89/92/92+ has the same problem with memory leaking, as I haven't
checked. (I
wonder because I saw an example in the manual somewhere showing a
program
construction that would cause a memory leak unless the 89/92/92+ are
smart
enough to know when a Goto branches outside of a loop. You wouldn't
think
that TI would promote bad coding style in the manuals.) But generally, I
don't use Lbls or Gotos at all (except for menus or toolbars that are
essentially Gotos, and Lbls are required) because I never need them
since I
use a different coding style than the one I used to.

--Travis






References: