realbasic-nug
[Top] [All Lists]

Re: Listbox memory leak

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Listbox memory leak
From: Jon Daniels <apex at forked dot net>
Date: Wed, 27 Feb 2002 15:05:31 -0900
Yes, I submitted a bug report which showed a memory leak when using a listbox, however it only occurs if you dragged the multi-column listbox control into your project. If you use the single column control and specify how many columns to use by code or via the properties window it doesn't leak. I think someone else mentioned it on the developer list, which is probably where this thread should be =]

Here's a copy of the report:

I was tracking down some memory leaks in my application and i found a leak in some basic listbox routines. This code is in a mode 2 timer with a 1000 (1 second) interval. This leaks about 10KB each time it's run. This ONLY leaks if the listbox control is the one which defaults to two columns, no matter what the columnCount property is actually set to. The more data and rows added the bigger the leak.


Oh yes, i forgot to mention the best part. I was using the example of Runtime() from the Reference Guide to check for memory leaks. I just added deleteallrows(). Quite Ironic that the code to check for memory leaks, leaks. =]

dim i, total as integer

  total=Runtime.ObjectCount
  listbox1.deleteAllRows
  For i=0 to total-1
    Listbox1.addrow str(Runtime.ObjectID(i))
    Listbox1.Cell(i,1)=Runtime.ObjectClass(i)
    Listbox1.Cell(i,2)=str(Runtime.ObjectRefs(i))
  Next
  EditField1.text=str(Runtime.memoryUsed)

Reproduce:

Sub Action()
dim i as integer

  listbox1.deleteAllRows
  For i=0 to 100
    Listbox1.addrow "something"
  Next

End Sub

Workaround:
Use single-column listbox control.


Regards,
Jon Daniels

On Wednesday, February 27, 2002, at 07:11 AM, jda wrote:

I've found that when you open a window that contains a listbox, there is leak of 2 handles (about 200 bytes). Anyone else seen this? 4.0.2fc5.

I've REALbugged it, with a small sample project.

Jon

---
Subscribe to the digest: <mailto:realbasic-nug-digest at lists dot realsoftware dot com>
Unsubscribe:
<mailto:realbasic-nug-off at lists dot realsoftware dot com>




<Prev in Thread] Current Thread [Next in Thread>