cog icon indicating copy to clipboard operation
cog copied to clipboard

Memory leak in Cog when using local variables

Open Higs360 opened this issue 3 years ago • 1 comments

Hello,

I have noticed a memory leak in Cog when a local variable is used inside a function called from a timer. Here is the code sample:

function SetDateTimeText() { //Get the current date let currentDate = new Date();

    //Format the date/time string
    let dateString = currentDate.toLocaleDateString('default', { weekday: 'long' }) + ", " +
        currentDate.toLocaleDateString('default', { month: 'long' }) + " " +
        currentDate.getDate().toString().padStart(2, '0') + ", " +
        currentDate.getFullYear().toString() + " " +
        currentDate.toLocaleTimeString();

    //Set the date/time text
    document.getElementById("DateText").innerHTML = dateString;
}

Function SetDateTimeText() is called from a timer function that is called every 250ms. Within a few minutes the Cog browser uses up all the available ram and Linux forces it close. Commenting out the line "let dateString=" removed the problem. The date/time will of course not update, but the memory leak will be gone. Can anyone please comment on this issue?

Higs360 avatar Feb 16 '22 17:02 Higs360

This looks like a WebKit bug, can you report to bugs.webkit.org please?

philn avatar Feb 16 '22 19:02 philn