Re: [SailfishDevel] QML arrays and memory leak

2015-05-04 Thread Tomasz Sterna
Dnia 2015-05-04, pon o godzinie 22:20 +0200, Kim Foder pisze:
> 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?

Possibly you are creating/destroying values so fast, that GC does not
have time to kick in. Maybe try calling QJSEngine::collectGarbage() [1]
manually every few iterations. (QQmlEngine subclasses QJSEngine)

[1] http://doc.qt.io/qt-5/qjsengine.html#collectGarbage

-- 
 /o__ 
(_<^' No problem is insoluble.

___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org


Re: [SailfishDevel] QML arrays and memory leak

2015-05-04 Thread Peter Kovacs

Hi Kim,

ohh! Okay!

Have you tried splice instead?
Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [ , … ] ] ] )
I think maybe something like:

accarr.splice(0,1,)

Looks more neat and it is in the normal javascript canon. Did not find 
the documentation on javascript and qt quick in the rush.

Hope it helps you as a work around.

Peter

On 04.05.2015 23:08, Kim Foder wrote:

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" :

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();

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-unsubscr...@lists.sailfishos.org

___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org


___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org


Re: [SailfishDevel] Pull data in background

2015-05-04 Thread Nicolas Cisco
Thansk Andrey!, i managed to do it with dbus, for the record i've written a
blog post with the code:
http://nckweb.com.ar/sailing-code/2015/05/04/closing-an-application-without-killing-the-main-loop/

Tomasz Sterna, i didn't know that telepathy protocol existed nor it was
implemented on sailfish. Are there some example, documentation, or sth to
read about how to use it?.

Thanks everyone!.


2015-05-04 6:02 GMT-03:00 Andrey Kozhevnikov :

>  you need to do it in separate class and implement dbus service for
> showing running instance when click icon again. try to do it yourself and
> tell me if you will not success, i'll give you minimal example.
>
> 04.05.2015 06:09, Nicolas Cisco пишет:
>
> I've create the gui view and set "setQuitOnLastWindow" to false. The
> problem i'm having is that when the app gui is closed (the app continues
> running on background), but the user can't open it again. How can i reopen
> the gui view when the user clicks on the menu button of the app?.
>
>  The main code:
>
>> int main(int argc, char *argv[])
>> {
>>  // SailfishApp::main() will display "qml/template.qml", if you need more
>>  // control over initialization, you can use:
>>  //
>>  // - SailfishApp::application(int, char *[]) to get the QGuiApplication
>> *
>>  // - SailfishApp::createView() to get a new QQuickView * instance
>>  // - SailfishApp::pathTo(QString) to get a QUrl to a resource file
>>  //
>>  // To display the view, call "show()" (will show fullscreen on device).
>>  //return SailfishApp::main(argc, argv);
>>  QGuiApplication *app = SailfishApp::application(argc, argv);
>>  QQuickView *view = SailfishApp::createView();
>>  app->setQuitOnLastWindowClosed(false);
>>  view->setSource(SailfishApp::pathTo("qml/background.qml"));
>>  view->show();
>>  MyTimer t;
>>  qDebug() << "Running!";
>>  int ret = app->exec();
>>  qDebug() << "Closes!" ;
>>  return ret;
>> }
>
>
>  MyTimer is just a class inherited from QTimer which prints "Running"
> each 3 secs.
>
> 2015-05-02 23:50 GMT-03:00 Andrey Kozhevnikov :
>
>>  Just make gui view in your application creatable by request and do not
>> quit application when window is closed.
>>
>> 03.05.2015 06:27, Nicolas Cisco пишет:
>>
>>  Hi,
>> i'm developing a messaging app (server and client) for a subject at
>> university. The proyect involves developing a server with a REST protocol
>> and an android application. In order to have a real case to use it to
>> compare developing an app for android and salifish, i thought that it would
>> be a good idea to also implement the client for salifish.
>>
>>  The protocol is quite simple, i already managed to develop the server,
>> tested via terminal and send messages using a simple qml app (basically i'm
>> doing ajax calls). My problem is how should i poll notifications and
>> messages. I have to periodically send an ajax call/http request to an url
>> (eg: http:///notifications) and the server will answer me
>> with a json with all the new messages.
>>
>>  My first idea is that the qml app pulls the data directly, but, if the
>> app is closed, no more data is pulled. Can the qml app start a service
>> (which runs on the backgound) in order to continue the pulling of data?.
>>
>>  My second idea is to run a daemon which periodically pulls displays
>> notification and communicates with the qml app via dbus. But, i've read
>> that daemons aren't allowed in harbour apps, i want to use this prototype
>> as a real test case of what will be shipping an app to Harbour.
>>
>>  Which would be the correct / recommended way to pull information from a
>> server periodically (in the background)?.
>>
>>  Regards,
>> Nicolas.
>> --
>> Nicolas Cisco
>> www.nckweb.com.ar
>>
>>
>>  ___
>> SailfishOS.org Devel mailing list
>> To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
>>
>>
>>
>> ___
>> SailfishOS.org Devel mailing list
>> To unsubscribe, please send a mail to
>> 
>> devel-unsubscr...@lists.sailfishos.org
>>
>
>
>
>  --
> Nicolas Cisco
> www.nckweb.com.ar
>
>
> ___
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
>
>
>
> ___
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to
> devel-unsubscr...@lists.sailfishos.org
>



-- 
Nicolas Cisco
www.nckweb.com.ar
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Re: [SailfishDevel] QML arrays and memory leak

2015-05-04 Thread Kim Foder
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" :
> > 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();
> > 
> > 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-unsubscr...@lists.sailfishos.org

___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org


Re: [SailfishDevel] QML arrays and memory leak

2015-05-04 Thread Peter Kovacs
Why use an array and not a vector or an Hash map?
 Am 04.05.2015 22:20 schrieb "Kim Foder" :

> 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();
>
> 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-unsubscr...@lists.sailfishos.org
>
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

[SailfishDevel] QML arrays and memory leak

2015-05-04 Thread Kim Foder
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();

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-unsubscr...@lists.sailfishos.org


Re: [SailfishDevel] 回复:Re: could we support hw overlay from gst-droid?

2015-05-04 Thread Mohammed Hassan
On Mon, May 04, 2015 at 12:04:57PM +0300, Tone Kastlunger wrote:
>  Ok I see, so the stack is actually:
>  lipstick -> QTGStreamer -> GStreamer -> OpenGLES.

QTGStreamer is not used at all.

>  In that case, perhaps a subsurface can do the job.
>  Thing is, how does the upstream stack handle it? AFAIK subsurfaces are
>  not available yet in Qt 5.1..

Which upstream stack? We are using Qt 5.2 BTW.

Cheers,

P.S. Please do not drop the mailing list from the conversation.
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org


Re: [SailfishDevel] Pull data in background

2015-05-04 Thread Andrey Kozhevnikov
you need to do it in separate class and implement dbus service for 
showing running instance when click icon again. try to do it yourself 
and tell me if you will not success, i'll give you minimal example.


04.05.2015 06:09, Nicolas Cisco пишет:
I've create the gui view and set "setQuitOnLastWindow" to false. The 
problem i'm having is that when the app gui is closed (the app 
continues running on background), but the user can't open it again. 
How can i reopen the gui view when the user clicks on the menu button 
of the app?.


The main code:

intmain(intargc,char*argv[])
{
//SailfishApp::main()willdisplay"qml/template.qml",ifyouneedmore
//controloverinitialization,youcanuse:
//
//-SailfishApp::application(int,char*[])togettheQGuiApplication*
//-SailfishApp::createView()togetanewQQuickView*instance
//-SailfishApp::pathTo(QString)togetaQUrltoaresourcefile
//
//Todisplaytheview,call"show()"(willshowfullscreenondevice).
//returnSailfishApp::main(argc,argv);
QGuiApplication*app=SailfishApp::application(argc,argv);
QQuickView*view=SailfishApp::createView();
app->setQuitOnLastWindowClosed(false);
view->setSource(SailfishApp::pathTo("qml/background.qml"));
view->show();
MyTimert;
qDebug()<<"Running!";
intret=app->exec();
qDebug()<<"Closes!";
returnret;
}


MyTimer is just a class inherited from QTimer which prints "Running" 
each 3 secs.


2015-05-02 23:50 GMT-03:00 Andrey Kozhevnikov >:


Just make gui view in your application creatable by request and do
not quit application when window is closed.

03.05.2015 06:27, Nicolas Cisco пишет:

Hi,
i'm developing a messaging app (server and client) for a subject
at university. The proyect involves developing a server with a
REST protocol and an android application. In order to have a real
case to use it to compare developing an app for android and
salifish, i thought that it would be a good idea to also
implement the client for salifish.

The protocol is quite simple, i already managed to develop the
server, tested via terminal and send messages using a simple qml
app (basically i'm doing ajax calls). My problem is how should i
poll notifications and messages. I have to periodically send an
ajax call/http request to an url (eg: http:///notifications) and the server will answer me with a json
with all the new messages.

My first idea is that the qml app pulls the data directly, but,
if the app is closed, no more data is pulled. Can the qml app
start a service (which runs on the backgound) in order to
continue the pulling of data?.

My second idea is to run a daemon which periodically pulls
displays notification and communicates with the qml app via dbus.
But, i've read that daemons aren't allowed in harbour apps, i
want to use this prototype as a real test case of what will be
shipping an app to Harbour.

Which would be the correct / recommended way to pull information
from a server periodically (in the background)?.

Regards,
Nicolas.
-- 
Nicolas Cisco

www.nckweb.com.ar 


___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail todevel-unsubscr...@lists.sailfishos.org




___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to
devel-unsubscr...@lists.sailfishos.org





--
Nicolas Cisco
www.nckweb.com.ar 


___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org


___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Re: [SailfishDevel] Keeping background process running in Sailfish OS

2015-05-04 Thread Tomasz Sterna
Dnia 2015-05-03, nie o godzinie 05:08 +, Taixzo pisze:
> Is there a way to make an app launch a daemon process that does not get 
> killed by this?

It is very easy to launch a user-systemd lever service.
Just create .service descriptor file and "systemctl --user start ..."
it.

If it becomes RAM hungry and OOM Killers slaps it, systemd will just
restart it. If you code your daemon to behave on sudden death, no harm
should be done.

It is also very easy to control your service programatically with
systemd D-Bus API. See my pebble[1] app for reference.


[1] https://github.com/smokku/pebble/blob/master/app/pebbledinterface.cpp#L123

-- 
 /o__ Q: What do agnostic, insomniac dyslexics do at night?
(_<^' A: Stay awake and wonder if there's a dog.

___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org