[SailfishDevel] QML arrays and memory leak

Kim Foder Kim at foder.dk
Mon May 4 21:08:57 UTC 2015


Hi Peter

> Why use an array and not a vector or an Hash map?

As far as I know those are not supported under javascript, otherwise a vector 
would have been my first choice, an Hash map is overkill for my needs, I only 
need to add to the end, and always need sequential read.

I am tempted to move the business part to C++, but I'm trying to do as much as 
possible in QML (as an exercise).

/Kim

> 
>  Am 04.05.2015 22:20 schrieb "Kim Foder" <Kim at foder.dk>:
> > 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?
> > 
> > Thanks.
> > 
> > Kim
> > _______________________________________________
> > SailfishOS.org Devel mailing list
> > To unsubscribe, please send a mail to
> > devel-unsubscribe at lists.sailfishos.org



More information about the Devel mailing list