Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3748] iOS: setInterval leaks CFStrings, CFDates and KrollInvocations

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-05-25T18:24:55.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2011-21
ComponentsiOS
Labelsn/a
ReporterDawson Toth
AssigneeBlain Hamon
Created2011-04-26T15:10:02.000+0000
Updated2011-05-25T19:11:03.000+0000

Description

The Problem

setInterval leaks objects (and memory) on iOS. Even without anything in it, this can still be observed.

Sample Code

If you are feeling particularly adventurous, lower the period of the below code to 1 instead of 30. It will increase the rate of the leak and slow your computer down a bit, but the same behavior can be observed at higher periods such as 30 or 200. I did not test on anything longer than 200.
function checkInterval() { }
setInterval(checkInterval, 30);
I ran the above code alone in an app.js using XCode's "Profile" > "Allocations" feature. It leaks at a rate of approximately 100 CFStrings, 100 CFDates, and 30ish KrollInvocations per second.

Associated Helpdesk Ticket

There isn't one. I noticed this in one of our co-dev apps.

Comments

  1. Blain Hamon 2011-05-25

    Timers, when running, keep the meter running on autorelease pools. This adds a new autorelease pool to stop that.
  2. Eric Merriman 2011-05-25

    Verified fixed with SDK build r364c307e. Verified leak prior to verifying fix. With fix memory allocation stayed stable on iOS 4.3.3 with iPhone 4. Closing.

JSON Source