Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry
My Carrier: Mobifone

CPU and Memory management in BB10

I've just figured out that my own program is using alot of CPU (>40) and memory (~10) when it is running. In main page, I attach all of qml, file picker, music player, q timer. I think that is the reason. Is it right? And how i can reduce the cpu and memory usage?

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: CPU and Memory management in BB10

Try running different apps so you can compare their functionality and resource usage.

I think you'll find that 10MB is totally normal, for even the most basic Cascades app.

CPU usage would depend on what's actually *happening*, not just what you've integrated into the app. The use of QML will itself not directly affect CPU usage in most apps, unless you've made the mistake of doing the "heavy lifting" entirely from JavaScript.

The file picker should be irrelevant to CPU.

The music player will obviously require CPU as it runs, though 40% sounds high. Note, if you're using the diagnostic overlay on the Dev Alpha (where you top-left corner swipe while on the Home screen), then the CPU value you see combines both cores, so 40% probably means one core is using 80%, which is a LOT.

The QTimer could also be involved... depends entirely what you're using it for, how often it's firing, etc.

Anyway, find similar apps in App World and compare. Maybe for what your app is doing (you didn't say what it does) it's a reasonable amount.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: CPU and Memory management in BB10

FWIW 10MB is a very small footprint for a cascades app, thats more or less the standard app footprint, so nothing to be worried about there.
Like all of my posts
Please use plain text.
New Contributor
_harolde
Posts: 5
Registered: ‎05-06-2012
My Device: Bold 9900
My Carrier: Rogers

Re: CPU and Memory management in BB10

I had some system sounds attached to one of my pages, and that caused a 50% CPU load, that wouldn't stop until the app closed.

 

Not sure if it was something I had done wrong, but once I removed it, the CPU would act normally.

 

At minimum, if you are worried about it, segregate each seperate qml page and see what load they use.

Please use plain text.
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry
My Carrier: Mobifone

Re: CPU and Memory management in BB10

Thanks all you guy. Because of the system sounds, cpu is always >40.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: CPU and Memory management in BB10

Can you guys post more on this, like a code sample showing how you're setting up those sounds? This sounds like a serious system bug, if they cause high CPU even when the sounds are not actively playing.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
New Contributor
_harolde
Posts: 5
Registered: ‎05-06-2012
My Device: Bold 9900
My Carrier: Rogers

Re: CPU and Memory management in BB10

[ Edited ]

At the beginning I had:

import bb.multimedia 1.0

 

and as an attached object:

 

attachedObject: [

SystemSound{

 id: fstSound

 sound: {

 SystemSound.DeviceUntetherEvent

}

}

]

 

I just added it back in to my main project,  and without calling it in the file the CPU usage went back up to 50% and stayed there.

 

I guess I should put that up as a bug?

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: CPU and Memory management in BB10

how are you monitoring cpu usage or memory usage? are you using the onscreen swipe debug info or the QDE's QNX System Information perspective?

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: CPU and Memory management in BB10

Wow, that sure looks like a nasty bug.  Yes, please report it!

 

I just confirmed it too, with code from the documentation at https://developer.blackberry.com/cascades/documentation/design/audio_video/playing_a_system_sound.ht...

 

Merely adding the SystemSound definition to my main.qml and running the app, even though the sound never plays, results in "CPU 43 0 0" up to "CPU 50 0 0" appearing in the diagnostic overlay. I believe that means one core is sometimes getting pegged at 100% CPU.

 

Here's the log output possibly associated with this, though it gives no hint (at least to me) that there's a problem.

08:50:32.287 <appname> default 9000  START 1 SystemSoundPrivate::SystemSoundPrivate
08:50:32.287 <appname> default 9000  => END 1 ( 0 ms):
08:50:32.287 <appname> default 9000  START 1 SystemSound::setSound
08:50:32.287 <appname> default 9000  START 1 SystemSoundPrivate::setSound
08:50:32.287 <appname> default 9000  START 1 multimedia::toString
08:50:32.287 <appname> default 9000  multimedia::toString: sound=3
08:50:32.287 <appname> default 9000  => END 1 ( 0 ms):
08:50:32.287 <appname> default 9000  SystemSoundPrivate::setSound: sound="event_camera_shutter"
08:50:32.287 <appname> default 9000  START 1 SystemSoundPrivate::send
08:50:32.287 <appname> default 9000  SystemSoundPrivate::send: sound=3, msg="prepare_sound"
08:50:32.287 <appname> default 9000  START 1 multimedia::toString
08:50:32.287 <appname> default 9000  multimedia::toString: sound=3
08:50:32.287 <appname> default 9000  => END 1 ( 0 ms):
08:50:32.287 <appname> default 9000  SystemSoundPrivate::send: QMap(("dat", QVariant(QVariantMap, 
QMap(("sound", QVariant(QString, "event_camera_shutter") ) )  ) ) ( "id" ,  QVariant(QString, "0") ) 
( "msg" ,  QVariant(QString, "prepare_sound") ) )
08:50:32.287 <appname> default 9000  => END 1 ( 1 ms):
08:50:32.287 <appname> default 9000  => END 1 ( 1 ms):
08:50:32.287 <appname> default 9000  => END 1 ( 1 ms):

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
simon_hain
Posts: 15,942
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: CPU and Memory management in BB10

perfect for a pocket heater app - but not so good for everybody else :smileyhappy:
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.