Languages

Menu
Sites
Language
App freezes when running long recursive function
Hi I am currently developing a scanner app which scan every file in device media storage.And it detects infected files.When there are small number of files in the emulator(i am using emulator here)then it is fine even if I scan the all files in emulator three to four times without terminating the app.But if there are large numbers of files(more than 1000) in the emulator then app freezes if i run the scanning thread again without terminating the app.Please help me out over this issue. thanks in advance.

Responses

5 Replies
colin Rao

Are you running the long recursive function in background? I means run it in another thread, but not in the main app UI thread.

Sourabh Rudrawar
Yes I am running recursive function in background,and I am using SendUserEvent() method to send event to main thread.I am using 2.2.1 version here.
Alex Ashirov

Hi,

I don’t know details about your app. But in any case it’s better to avoid recursion at all.

colin Rao

Is it possible a resource/handles not been released while you re-run the scanning thread again?

Alex Ashirov

Right. All local/automatic/stack resources allocated during each recursive call are still allocated while the recursion isn’t completed. It’s why it’s recommended to avoid recursion whenever it’s possible. More than 1000 recursive calls is too depth recursion and should be re-implemented, e.g. by loop.