× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On Fri, 20 Jun 2003, Beppe Costagliola wrote:
>
> >  string = createString(myString);
> >  string = trimString(string);
>
>  we actually have 2 java objects to free and suggests how to correct the
>  code.

The reason for this is that they used the object reference "string"
twice in the code above, without freeing the first one.

Think about it...  createString() creates a new string, and trimString()
also creates a new string.  Obviously, you need to free two strings,
right?   Just freeing it once isn't going to clean everything up.

>
> >  for i = 1 to 100;
> >    string = createString(myString);
> >    newObject = someMethod(string);
> >    . . . .
> >  endfor;
>
>  At the end of the loop:
>
> > FreeLocalRef(String);
> > FreeLocalRef(newObject);
>

As long as the "FreeLocalRef" calls are INSIDE the loop, this should be
fine.   Two objects are created, and you have two FreeLocalRefs... that's
what you want.   When running that in a loop, it creates 200 objects, and
frees 200 objects...   that's what you need.

Whereas, if you had put the "FreeLocalRef" calls outside of the loop,
it would still create 200 objects, but only free 2 of them.

Make sense?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.