[SailfishDevel] QML arrays and memory leak

Thomas Tanghus thomas at tanghus.net
Tue May 5 01:12:50 UTC 2015


On Monday 04 May 2015 22:20:17 Kim Foder wrote:
> Hi
> 
> For some time I have been battling a memory leak in my pedometer app, after
> a lot of experimentation, I have found the problem to be my use of arrays
> (probably)!
> 
> Whenever I receive an acceleration measurement, some statistical
> calculations are made, which results in one float pr. measurement.
> 
> As I need the measurements for a certain time for further statistical
> analysis, the results are stored in an array, used as an traveling window
> like this:
> 
> accarr.shift();  // the array is pre-initialized with empty elements.
> accarr.push(<float>);
> 
> This works great, but it leaks memory fast, and after some time (between 1 &
> 2 hours) the OS kills all running apps!
> 
> Any ideas how I can solve this?

Do you remove the obsolete values from the array? You don't show that in the 
code snippet.

-- 
Med venlig hilsen / Best regards

Thomas Tanghus


More information about the Devel mailing list