October 6, 2010

itoooo itoooo
Lab Rat
3 posts

QScriptEngine memory usage

 

Hi,

I’ve been playing around with QScriptEngine and I noticed it seems to use a lot of memory, on my platform (ARMv5 linux) the first QScriptEngine object instanciated allocates a 11540 KB memory block, and the next engines allocate a 2592 KB memory block each. (shown by pmap’s output)

This behavior doesn’t seem odd to me, but I am wondering :

  • can those buffers be tweaked in QT’s source code ?
  • what is the purpose of such huge buffers ?

Thank you very much !

3 replies

October 6, 2010

itoooo itoooo
Lab Rat
3 posts

Tracking down the source of the memory usage, I could notice the first QScriptEngine creates a thread (enabled by the USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY option), this thread allocates 8MB on my system for its stack.

This thread seems to be shared between all script engines, that’s why there is a difference between the first script engine and the others.

Still trying to optimize the memory size for each script engine (seems like the interpreter maps a 2M memory block)

October 7, 2010

itoooo itoooo
Lab Rat
3 posts

I finally tracked down the other big memory block, it is instanciated by the RegisterFile class, child of the Interpreter class.

By default it allocates 2MB for the virtual machine’s stack.

I’ll try to play around with the capacity to see if it is possible to optimize it.

October 7, 2010

itoooo itoooo
Lab Rat
3 posts

The last thing you can tweak if you have a small amount of memory on your system is the BLOCK_SIZE allocated by the collector, the default size is 256K if QT is not compiled for symbian nor wince, which can be much more than your scripts need.

 
  ‹‹ QtMobility Camera example with webcam?      It’s very very dificult to develop an Mobile APP for Nokia with QtMobility! Any one help me pls! ››

You must log in to post a reply. Not a member yet? Register here!