×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249

    Application hangs randomly

    I have an application that works fine in general when I test it on both nokia 6680 and 7610. But occasionally the user interface portion of it hangs and won't respond unless the phone is restarted. From all my testing, this "hanging" is random at different stages of the application.

    The application communicates with the server using soap. Networking and user interface are handled in separate threads.

    Unfortunately, due to the nature of the application, it creates quite a few temp objects within most methods because any user invoked command requires a refresh of all data (i have already done all the basic optimization techniques to keep this as low as possible, but due to nature of program, there's only so much I can do).

    Any ideas or guesses why it might hang? Does it have anything to do with the garbage collector? I do NOT invoke System.gc() at all in my application. Should I be doing so?

    Any help or insight at all would be very appreciated. It's quite urgent.

    Many thanks.

  2. #2
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    To add to the above question, is there, if any, risk in using System.gc() in any part of the program?

    Is the garbage collector always invoked automatically by the runtime? Have there been cases where the garbage collector fails to do so?

    Thanks alot.

  3. #3
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    As an update:

    I am now calling system.gc() rather regularly. Every 5 "commands", even at startApp and destroyApp...

    But it still hangs.

    Any ideas or guesses... thanks!

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    Is the application hanging the entire phone? You have to restart the phone, you can't just "red-button" back to the main menu, then close the application through the task menu?

    If the entire system is hanging, then it can't really be because you have done something wrong... you should not be able to hang the phone to that extent from a Java app. Of course, you can hang it, many devices can be frozen, rebooted or whatever if you know the bugs in the JVM!

    You say the user interface hangs... is this so, or is the entire application? I mean, can you verify that other threads in the application are still running? Is the hang associated with anything... running for a certain time, or network connection for example.

    Garbage collectors usually work reasonably well. Java applications invariably create huge amounts of garbage, so if the gc was fundamentally flawed, you'd know pretty quick! I'm not aware of any specific gc problems on those phones, although running the garbage collector may be slow. As a rule, I'd avoid invoking the gc manually on DP2 Series 60s.

    You may have to resort to the old-fashioned technique of ripping bits of the program out until it stops happening!

    Cheers,
    Graham.

  5. #5
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    The entire app hangs and even the nokia soft command ("close") that annoyingly appears on every screen doesn't respond. Other functions in the phone work fine. Making calls, accessing sms-es etc. But I cannot for the life of me close the application. It just seems suspended on that same screen even after leaving it alone for more than 5 minutes. Thus, I resort to restarting it.

    UI and networking are handled in different threads. UI *should* not be relying on anything else. As far as I can tell, I haven't accidentally mixed them up throughout the application. The UI thread provides a splash screen, and allows user to cancel and return to last screen. (and yes, it has been tested)

    It hangs randomly, sometimes while it is handling networking (which has the worrying problem of the little [G] sign not disappearing until I restart the phone, even after minutes, but as far as I can tell, the telco doesn't bill me for this usage [using a prepaid] so I doubt it is retrieving any info at this point). Most times, it hangs when I invoke a command, which really stumps me because it hangs before it attempts anything. At one point, I displayed an alert for testing purposes before anything else in the program executes. That alert often time never appears before application freezes.

    I also have no timers (though I should start thinking about adding one to timeout excessively long networking operations). Also can obviously never crash it on the simulator. *sighs* If only simulators were the real deal... everything would work. But then I suppose it takes the fun out of forums.

    I haven't been able to prove it's the JVM's problem, nor have I been able to prove it's an error on my part. So yes. I already resorted myself to stripping the whole program apart and remodeling the entire thing *envisions sleepless nights ahead*.

    Any additional insights are welcome. Knowing someone out there thinks it's as baffling as I do seems to help keep my sanity slightly intact.

    Cheers.
    Last edited by lmtang; 2005-06-27 at 03:09.

  6. #6
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    Why is it not recommended to manually call System.gc() on DP2 Series 60? How about other platforms/phones?

    thanks and cheers.

  7. #7
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    Hmmm... now it seems it might not be the JVM after all....

    After the program UI thread hangs, I can move on to different screens, so I tried starting up a totally different Java app also using the WAP connection. It works.

    I'm officially stumped. The hanging is still at random screens. I hate this....

    [edit]

    I'm getting contradictory signals. If I add a whole bunch of junk info to take up space (for testing purposes), some 50 Vectors worth, the application becomes less stable and starts to hang near the start rather than after 20+ user commands.

    And when I add this extra stuff, other java apps have problem executing properly. This cannot get anymore confusing.

    [/edit]
    Last edited by lmtang; 2005-06-27 at 08:12.

  8. #8
    Registered User
    Join Date
    Sep 2003
    Location
    London, UK
    Posts
    5
    Hi,

    I know exactly what you mean. I'm experiencing a very similar problem. This was to some extent stabilised by ensuring that the paint() method wasn't called if it hadn't completed. This workaround is described in the following post.

    http://discussion.forum.nokia.com/fo...416#post151416

    It seems though that my app still crashes randomly. For those who remember, this behaviour is somewhat reminiscent of the 6600 MontyThread errors when that device came out.

    As Graham says, it's going to be a case of pulling the app apart until the area of code is isolated - not looking forward to it.

  9. #9
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    System.gc() on the DP2 Series 60s has a tendancy to be very slow - much slower than on the DP1 60s. It won't cause problems other than performance, though.

    What is your UI? Canvas? Form? Can you make it a form, and output information to it from each thread, so you can see what has hung and where?

    Graham.

  10. #10
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    Sorry for the long absence.
    Thanks for all the help. Followed every lead (even the paint() problem, thanks osullivp) but found nothing. Due to my deadline, i've been adding on more code to complete the project regardless of the hanging and now, needless to say it starts hanging alot quicker.

    In answer to your question graham, I am using a form for my UI. Unfortunately, my company prefers it to be filled with color and to be more fancy than the available api's, so I do invoke paint at every screen. I've noticed that all that painting (whenever I paint a menu) takes up quite a bit of memory, especially when the number of items begins to increase. I'm beginning to wonder if that may be a big part of it. Anyone have any idea on this?

    I tried outputting free memory on every screen (before anything else is run). It seemed to me that free memory was rather abundant, and at those occasions when it decided to hang, free memory never even gets output, meaning it hung before the first line of code at commandAction was even invoked.

    So I thought perhaps it was memory fragmentation. Tried that trail too, obviously still nowhere near.

    I'm actually only going to be able to fully devote my time to this problem next week when I'm done coding. So will keep you all posted.

    Thanks a bunch for the help so far. I really appreciate it.

    Cheers.

  11. #11
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    Just to add. the free space output was done on the phone itself, not the emulator (the latter of course never crashes) in case some start wondering.

    tried using the memory monitor that comes with WTK (though I'm using netbeans, so used it within the IDE), but couldn't find any memory leaks. But, i need more time to thoroughly test that, so don't take my word on it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •