On 14/02/2007, at 10:48 AM, [EMAIL PROTECTED] wrote:

On Feb 13, 2007, at 23:31 UTC, Jeff Ayling wrote:

So, every time the fi.ReadAll reads the file a new TextEncoding
reference is added to the stack. Using the code from my original
post, the Runtime.ObjectRefs for TextEncoding increases by 1 each
time the ReadAll is called. Pop it in a Timer with 1 millisecond loop
and this grows to over 20,000 references within a few seconds.

Is this ok? Is this a problem that there are sooo many references to
textencoding even after the object is no longer needed?

It may not be a problem, but it does sound like a mistake in the RB
framework -- something's locking a TextEncoding object and not
unlocking it.  If this is an internal object that's used for a default
value, then this isn't important, but it'd still be neater if it were
fixed.

A more important test would be what happens if you pass a TextEncoding
object into ReadAll. If that gets its reference count incremented, but
not decremented, then this would cause a leak, and that's a serious
problem.

Best,
- Joe

--
Joe Strout -- [EMAIL PROTECTED]
Verified Express, LLC     "Making the Internet a Better Place"
http://www.verex.com/

Hi Joe,

Thanks for your reply.

I adjusted the code based on your comment - is this what you had in mind?

  dim f as folderitem
  dim fi as textinputstream
  dim s as string


  f=GetFolderItem("notes.txt")
  fi=f.OpenAsTextFile
  s=fi.ReadAll(Encodings.UTF8)
  fi.close

...and yes, this code has the same result. The TextEncoding object reference count continues to grow.

So, this appears to be a leak? Is there anything I can do here apart from wait for a new release with a fix? Maybe use BinaryStream without specifying an encoding?

Thanks


Jeff



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to