WebContainers progressively slower

This is an odd one.

I built a control that displays a bunch of containers that can be scrolled.
It has maybe 150 containers at a time.

The first time I load it, it’s very fast.

Every time I go to it again, it becomes notably slower. Consistently slower even with the same contents. After a few times it becomes pretty much unusable.

I profiled it, and it looks like it’s using next to no time at all.
I dropped some debugging output that shows the entire process rounds to 0 seconds. I figured it may just be browser update issue and am calling updateBrowser – no difference.

Hopefully someone will have a tip. I’m about to have to find another method to show the data, and this is my 3rd attempt to get something that would look ok and perform in a reasonably fast manner. .

Can you try to isolate this as a sample project to see what could be happening? Are you adding event handlers with code (AddHandler) by any chance?

May it’s better to insert all containers into another container and move only this one, if possible. I did this in a desktop project, worked OK so far on Windows. And very good on macOS.

OK, I did some more work on it.

The page that loads them, let’s call it PageEditor for example.

It has a single container control that is a subclassed control. Within it I manage all the positioning, scrolling, doing things like expanding some or hiding some, etc.

If I call New PageEditor( myData ) it becomes increasingly slower.

If I have PageEditor.setData myData, and from within that clear out all old controls, it’s reasonably quick.

So I do have a workaround, it just took me a long time to get to it. It also suggests something is going on like a memory leak - or something.

Does this ring any bells?

That looks like something is not being properly cleaned up, yes, but without seeing some code or project it will be difficult to know what is it.

I will try to prepare a simple example

1 Like

Make sure you’re not using Static on any of your pages or controls. It’s a good way to inadvertently share data among all instances (and across Sessions).

Good tip. Thanks.