webix._events memory leak

I am experiencing disturbing memory leaks in my webix app. When I profile my app I can determine that all of the leaks are contained in the webix namespace. A large part of leaks occur in the webix._events array.

For example this snippet: http://webix.com/snippet/ac30ae9a will cause the events array to grow substantially. Event worse when you capture any objects in the event handlers, that will worsen the problem exponentially.

At the moment, if you attach an event handler, webix will create a new entry in the events array. However, it is not possible to replace an event handler. I think that most of the time, replacement, is what is intended, not a duplicate handler for the same event/element. In the snippets case, refreshment of form elements cause addition of the same event handling each time.

Hi,

We will patch the issue with “onchange” event handler in the next update ( drop an email to support@webix.com if you need the fix ASAP )

However, it is not possible to replace an event handler.

You can use

webix.event(node, name, handler, { id:"123" });

where id is any constant value. As result, each time when webix.event is called, the event handler will replace the same slot in webix._events array.

There is a bit more complex issue with not removing all reference

Thanks, for the quick resonse.

Another example: this is another seemingly innocent piece of code that will result in a memory leak. I just copy pasted this code: http://webix.com/snippet/3cc34332 to implement a loading view for my app. It creates a loading view and hides and subsequently destroys the view. However, the event handlers for this view are not cleaned resulting in a serious memory leak. Using google profiler, 10.000 runs result in about 40 MB of leak.

So, creating and destroying webix components seem quite dangerous.

Just to demonstrate the severity of the problem, I have added a memory expansive array to the view. Now when you run create/destroy the view multiple times, the amount of memory used rises linearly: http://webix.com/snippet/3cc34332.

In the supplied example, used memory increases from 11 MB to 90 MB after 1000 creations/destructions.

Hello,

Thank you for the demo. I’m not sure that we will manage to solve the issue in the next release. But we will definitely fix the issue in one on the next releases.

As the workaround for Window you can use hide()/show() methods instead of close().