Page 1 of 1
Freezes I can't identify why or where?
Posted: Sat Feb 23, 2013 12:18 pm
by jesperbrannmark
Hi.
When I run in cocoa in the newer versions - 5.0, 5,1.. I get a lot of freezes of my program.
No error... nothing in the debugger that makes me identify why... no cpu or memory usage to tell me whats going on.
It happens more often if I don't have my main window as active window during startup (like if I check my mail while the program starts).
I can run the same code several times (without recomplile) and it freezes at different places in the program.
How can I find what is causing the problem? Is there any specific tools? Is there any more advanced logging?
I am not getting any errors at all..
Re: Freezes I can't identify why or where?
Posted: Sat Feb 23, 2013 12:33 pm
by wilbert
Is cpu load close to 0 or 100 ?
To monitor cpu load and memory usage, you can use PureMonitor
http://www.purebasic.fr/english/viewtop ... 27&t=53285
Re: Freezes I can't identify why or where?
Posted: Sat Feb 23, 2013 1:00 pm
by IdeasVacuum
It could be that your Anti Virus is interupting it.
Re: Freezes I can't identify why or where?
Posted: Sat Feb 23, 2013 1:33 pm
by Polo
Have you tried removing the code on SizeWindow event just to check?
Re: Freezes I can't identify why or where?
Posted: Sat Feb 23, 2013 2:45 pm
by jesperbrannmark
Hi.
No CPU use (from activity monitor), or just a tiny bit like 0.1% ...
No Antivirus
Resize - I dont even come so far in the code.
Most of the time it looks up on login screen (enter password etc), sometimes after a couple of characters - sometimes after pressing login and a progressbar is indicating where we are in login process.. sometimes when main window comes up and the webgadget show "what today look like" - sometimes when clicking a button - sometimes not at all.
it would have been so much easier if it was at a specific point every time... but it is not... so i really need some more in depth monitor (like the good old action replay cartridge on the amiga). It must be something in PB that is doing this, the question is what and why.
The code is to big to just cut out code and see when the problem stops.
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 3:10 pm
by jesperbrannmark
I removed all use of threads. This happens regardsless of debugger or if its a production executable.
It will freeze or crash and can do so on either;
1. First webgadget (most common crash) on the waitwindowevent (like in
http://www.youtube.com/watch?v=cpXq5YnD3mE&t=0m52s or
http://www.youtube.com/watch?v=cpXq5YnD3mE&t=1m05s )
2. First window everything just stops - no crash but have to force quit. No keyboard input working and just the rainbow wheel mouse (like in
http://www.youtube.com/watch?v=cpXq5YnD3mE&t=0m39s )
3. Random place some time in the program, with either the rainbow wheel OR the crash on waitwindowevent.
How can I debug this? Is there a trick? It has been in v5 and newer using cocoa... but also sometimes with carbon but not so frequent...
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 3:38 pm
by wilbert
It's hard to tell if you have no code to test with.
Personally I haven't encountered this. It could have to do with memory management.
The Cocoa version of PureBasic uses an autorelease pool so allocated memory that isn't used anymore is released not immediately but at certain points in time.
Have you monitored the amount of memory your application consumes ?
Crashes on WaitWindowEvent could also be a PureBasic bug.
As far as I know (Fred can correct me if I'm wrong), WaitWindowEvent is the place where the items in the autorelease pool are released.
If something in there was already released manually (caused by a bug), the application can crash when it tries to release an object for the second time.
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 3:50 pm
by jesperbrannmark
The memory usage is what to expect. Sometimes it bounces up high, but not with these crashes. The thing is the compiled program itself is just getting started upon the crashes and it seems it doesnt matter much what I do with my code (I have a errorhandler installed but its not being called ever upon these crashes or if it it gives a BUS error or a Segment Violation error or at best a IMA and the code line never tells any insight to the real problem).
I think it has nothing to do with WaitWindowEvent. In the back of my head I think this is something in a thread created by a library in PB. Like maybe network library or sprites library does something in a seperate thread and if there is a problem in a thread usually it crashes on waitwindowevent.
The problem is I have no tools to check WHAT is the real problem here. I am sure my code is crappy, no doubt about it, but the problem occurs because of something in PB since V5... Is there any way of compiling the code and running via Xcode debugger somehow? I cant redistribute the code to everyone since its my commercial project and I cant just cut out a piece of code that gives the error so I have to have the whole thing.
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 4:29 pm
by wilbert
With XCode comes a tool named Instruments. That might help you.
Once you have your application compiled with PureBasic, you can use it to monitor a lot of things.
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 7:36 pm
by J. Baker
Are you working with a window screen and mouse events?
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 10:13 pm
by jesperbrannmark
Hi.
Yes i work with window event, both NewEventHandlerUPP_ (carbon) and currentEvent = oMsg(0, sharedApplication, "currentEvent") (cocoa) - but that comes later in the program. The crash (usually) occurs way before this.
Re: Freezes I can't identify why or where?
Posted: Tue Mar 26, 2013 10:16 pm
by J. Baker
The reason I asked about mouse in a screen is because my test app locked up when I tried to open another app while the test app was running. See this...
http://www.purebasic.fr/english/viewtop ... 96#p394396
Re: Freezes I can't identify why or where?
Posted: Wed Mar 27, 2013 3:44 am
by jesperbrannmark
Aha, no i am not using examinemouse... i use windowmousex/y only.
Re: Freezes I can't identify why or where?
Posted: Wed Apr 03, 2013 3:52 pm
by IdeasVacuum
Do you have your app running on Windows too? If not, it would be worth trying it.
For Windows apps, NirSoft have a number of handy tools. This one
http://www.nirsoft.net/utils/what_is_hang.html could be useful.