Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10093] Android: HTTPClient leaks function callbacks (ex: onload, ondatastream)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-08-14T16:01:18.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sSprint 2012-16 API, Release 3.0.0
ComponentsAndroid
Labelscore, module_xml, qe-review, qe-testadded
ReporterJosh Roesslein
AssigneeJosh Roesslein
Created2012-07-23T13:19:17.000+0000
Updated2013-09-05T17:37:39.000+0000

Description

It appears the HTTPClient never releases the function callbacks for on*** events (ex: onload). This can lead to memory referenced by variables in this function's scope getting leaked. Create an application with the attached app.js script. 1. Run the application and monitor with DDMS. 2. Click "Send XHR Request". 3. Repeat step #2 and see if the heap size continues to grow out of control. Expected: Memory referenced by the function callback should eventually get collected. Actual: Memory is never collected causing the heap to grow indefinitely.

Attachments

FileDateSize
app.js2012-07-23T13:19:30.000+0000868

Comments

  1. Josh Roesslein 2012-07-23

    Another cause of the memory leak seen in TIMOB-10040.
  2. Josh Roesslein 2012-08-07

    Created [PR #2687](https://github.com/appcelerator/titanium_mobile/pull/2687) to resolve issue.
  3. Josh Roesslein 2012-08-14

    Created [PR #2746](https://github.com/appcelerator/titanium_mobile/pull/2746) to back port fix into 2_1_X.
  4. Satyam Sekhri 2012-09-10

    The referenced memory gets collected. Verified on: Titanium Studio: 2.1.3.201209071738 Titanium SDK: 2.2.0.v20120907162025 Android Emulator v2.3 Runtime: v8
  5. jordi domenech 2012-11-13

    In TiHTTPClient.java, method setReadyState, you're calling: dispatchCallback("onreadystatechanged", null); but is "onreadystatechange" <-- notice there's no -d
  6. Josh Roesslein 2012-11-13

    Jordi, you saved the day! Thanks for catching this regression and typo. I have opened TIMOB-11751 to resolve this bug.

JSON Source