Scheduler Memory Leak Problem

Hi guys,

We are trying to accomplish update of event’s text periodically. For example; temperature of a chemical process(event) in machine.

If we use Dhtmlx Scheduler’s inner methods to update text of an event, memory & CPU usage is increasing constantly. Problem is not browser specific. We are evaluating dhtmlxScheduler v.4.1.0

We simulate updating event’s text as follows, updateEventText is called periodically for 254 events:

1 - ) Event text update using “setUserData”

[code]
var c = 0;
var updateEventText = function() {
// if we use setUserData to update event’s text periodically, there is a huge memory consumption
// The page doesn’t respond at all. After a while, for example, the Chrome tab crashes, when memory usage reaches ~1Gb.

    for(var machine_id in scheduler._events) {
        scheduler.setUserData(machine_id, "text", c);
    }
    c += 1;
    scheduler.setCurrentView();
}
setInterval(updateEventText, 500);[/code]

2 - ) Event text update using “updateEvent”

[code]
var c = 0;
var updateEventText = function() {
// if we use updateEvent to update event’s text periodically, there is also a huge memory consumption
// but this time we have 25% CPU usage all the time, plus 500 ms delayed changes can be seen after 1-2 second(s)

    for(var machine_id in scheduler._events) {
        scheduler.getEvent(machine_id).text = c;
        scheduler.updateEvent(machine_id);
    }
    c += 1;
}
setInterval(updateEventText, 500);[/code]

3 - ) Event text update using custom solution:

[code]
var c = 0;
var updateEventText = function() {
// here we update event text only on the rendered div - but this doesn’t propogate to the inner data
// that DhtmlX Scheduler is using. Memory usage is totally acceptable - there is not a huge CPU
// consumption.
// What could be done so DhtmlX Scheduler plugin methods perform this well?

    for(var machine_id in scheduler._events) {
        elem = scheduler.getRenderedEvent(machine_id);
        if(elem) elem.getElementsByClassName("event_metni")[0].innerHTML = c;
    }
    c += 1;
}
setInterval(updateEventText, 500);[/code]

Do you have any comments? What could be done to fix this? Is there anything planned for next releases?

Try to use the second approach but with a little modification

[code]for(var machine_id in scheduler._events)
scheduler.getEvent(machine_id).text = c;

scheduler.updateView();[/code]

So it will update all data in the loop and then use a single refresh operation for all events.

Also, you can replace scheduler._events usage with getEvents call, as first one is a private api and can be removed in next versions. It will not affect performance though

Hi again,

This approach is solving the CPU usage problem, but if you check the memory usage, it is increasing constantly.