Window.show memory usage

Not a problem as such but need some clarification.
I have a Desktop program with a function to loop through every record in a database (150,000 or more) and perform a complex calculation based on fields and dates and save the result into a record field.
The problem was that although all variables used were local and private the memory use as viewed in Mac Activity Monitor gradually increases and around the 40,000 record mark the system runs out of system memory (50gb used) and stops with an error message.
I couldn’t put my finger on it and moved all processes out of threads thinking it was creating too many at once but Activity Monitor was showing the queue function was sticking to 10 at a time as it should.
Turned out to be the progress window which informs the user of the progress percentage which is activated by a timer. Not that it was using any resources but the timer was calling the window.show event every time it needs to change the percentage.
I didn’t realise that if you call it again while it is already displayed it uses about 10mb of memory each time. I thought the instruction would be ignored if it was already visible as I just want to bring the present window to the front.
Has anyone else had this happen?

You could make an issue from this, i also would expect the show to be ignored if the instance is already shown.

I would expect it to trigger just a “Bring to front” Event.

Yes, I understand some resources are used to repaint the window if it needs to be brought to the front but the problem is the system doesn’t release the memory from the previous window.
It is there until you close the program.

1 Like

Are you doing anything in the Activated event of the Window?

What about the old case 42044 and case 43484?

No just changing the text in a label at about every 20th record.

Off topic, but whenever I read this, my immediate reaction is ‘can this calculation be done by the rdbms’?

Looping through the records one by one in Xojo is very slow in comparison.
But if it is possible to make the db do it, you might find you dont even need the progress bar.
Can you say what the calc is? / post some code?
Feel free to DM if you dont want it out in public