Jump to content

I may be doing something wrong resulting in a listview memory leak


ycomp
 Share

Recommended Posts

Hi.

I have memory leaks in my code... it is pretty obvious the general part of the program that does it. I can guess that it is one of 2 things there... either there are leaks from dealing with lots of arrays constantly being created... or it has something to do with listviews.

Seeing as the memory leaks stopped if I commented out a few lines from the listview code, I suspect that it is the listview not the arrays causing the problems.

But the problem is, what I'm doing is pretty straightforward.

I am populating a listview from a 2D array... for each element I am calling

GUICtrlCreateListViewItem

to create a new list view item. I also change the color of the item.

the other part of the code that is commented out here is the "clear the listview code" that i call at the start of each time i populate the list view.

_GUICtrlListView_BeginUpdate($hndListview)

_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hndListview))

The reason I can see the memory leaks quickly is because my code runs in a constant timer loop so it gets executed a few times a second.

So I am not sure why, if I am repopulating a listview a few times a second that it would cause memory leaks... does anyone know what I might be doing wrong?

Link to comment
Share on other sites

Hi.

I have memory leaks in my code... it is pretty obvious the general part of the program that does it. I can guess that it is one of 2 things there... either there are leaks from dealing with lots of arrays constantly being created... or it has something to do with listviews.

Seeing as the memory leaks stopped if I commented out a few lines from the listview code, I suspect that it is the listview not the arrays causing the problems.

But the problem is, what I'm doing is pretty straightforward.

I am populating a listview from a 2D array... for each element I am calling

GUICtrlCreateListViewItem

to create a new list view item. I also change the color of the item.

the other part of the code that is commented out here is the "clear the listview code" that i call at the start of each time i populate the list view.

_GUICtrlListView_BeginUpdate($hndListview)

_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hndListview))

The reason I can see the memory leaks quickly is because my code runs in a constant timer loop so it gets executed a few times a second.

So I am not sure why, if I am repopulating a listview a few times a second that it would cause memory leaks... does anyone know what I might be doing wrong?

You have created the memory leak.

If you use the release version or beta prior to 3.2.11.0 you have to use the GuiCtrlDelete if you use the GuiCtrlCreateListViewItem.

for Example:

For $index = _GUICtrlListView_GetItemCount($hWnd) - 1 To 0 Step -1
            $ctrlID = _GUICtrlListView_GetItemParam($hWnd, $index)
            If $ctrlID Then GUICtrlDelete($ctrlID)
        Next

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

thanks, that seemed to have helped greatly. I now have a much smaller leak.. like 8k every 10 seconds.. not sure if it is listview related or not. I guess arrays don't leak? I never have to explicitly delete an array object do I? (still fairly new to autoit and not really much of a vb expert.. )

Edited by ycomp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...