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
sreejond
Posts: 49
Registered: ‎03-27-2013
My Device: z10
Accepted Solution

Memory cleanup crash issue!!!

Hello everyone.

 

I am doing multithread in my app. In my new thread I use two signal and two slot.

 

Task of 1st signal & slot -

Given an object parameter in the signal I invoke a member function of this class in the slot.

 

Task of 2nd signal & slot -

Given the same object parameter to delete this object.

 

You can arise a quesiton why I am deleting memory in this way. Actually in my new thread using 1st signal & slot I want to download map tile from server. But in QT framework I didn't able to download map tile from my new thread. So, I use MoveToThread() to move my object of new thread to the main thread and let the main thread do it for me. But now when I want to free my memory I can't delete it from my new thread because main thread is working with it. So I introduse 2nd signal slot mechanism to free my memory.

 

All the thing is working well and good except, when I pan my map continuously & quickly it got crashed. Because my 1st signal & slot working with already deleted object by 2nd signal & slot.

 

Hopefully I make you all understand the situation, if you need further clarification please let me know. It's a very critical issue for me. Hopyfully you guys can help me.

Please use plain text.
Developer
Neurocode
Posts: 43
Registered: ‎12-16-2011
My Device: Torch 9800 & Playbook

Re: Memory cleanup crash issue!!!

Hi sreejond,

 

I have a similar scenario in my application, whereby I use another thread to load data for my main thread to use.  This is the approach that I took:

 

Main thread invokes, loader thread;

 

Loader thread creates data objects, loads data into them, and then passes them to main thread via a signal. (not forgetting to use MoveToThread() before emitting the signal).

 

Main thread receives the objects via a slot, and then stores and  uses the data objects.

 

Main thread deletes data objects at the appropriate time.

 

I think if you simplify what you are trying to do, you will get a better result. I would guess that your main thread knows when it is time to delete the objects, so it may as well manage (delete) them itself.

regards

Daniel - Neurocode
If my posts help, please click the Like button.

gymChronicles - helping you to keep motivated
Please use plain text.