Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screen Saver Question



I've reproduced the SysPref freeze problem :-). I have a suggestion about the cause (see below).

During debugging I found a bug in the .m file; there is a -release method which looks intended to free resources. The trick with ObjC is to free resources in the -dealloc method, like this:

- (void) dealloc {
    NSLog(@"Deallocating Saver3View");
    [messageRect release];
    [self clearVMArgs];
    [super dealloc];
}

-release decrements the reference-count on an object. When the ref- count reaches zero ObjC's runtime will call dealloc for you. When I made the change I see a rotating green line in screensaver's preview window.

For examples see: http://developer.apple.com/documentation/Cocoa/ Conceptual/ObjectiveC/index.html?http://developer.apple.com/ documentation/Cocoa/Conceptual/ObjectiveC/Introduction/ chapter_1_section_1.html

And the freeze-problem? I used NSLog to print debug messages to the Console:
2005-07-28 12:11:25.402 System Preferences[5789] Saver3View:initWithFrame
2005-07-28 12:11:25.455 System Preferences[5789] startVM ...
2005-07-28 12:11:25.455 System Preferences[5789] clearVMArgs ...
2005-07-28 12:11:26.061 System Preferences[5789] started VM ok
2005-07-28 12:11:26.787 System Preferences[5789] all ok so far


2005-07-28 12:11:26.838 System Preferences[5789] Apple AWT Couldn't start headless. SetApplicationIsDaemon returned -50
Look at this message ^^^^^^^^^^^^


<animateOneframe is called many times to display your message ...>
2005-07-28 12:11:35.969 System Preferences[5789] stopVM ...

'-stopVM' attempts to destroy the Java VM you created. Note the JNI VM unload information below

from http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/ invocation.html#wp16553
" Unloading the VM


The main thread cannot detach itself from the VM. Instead, it must call DestroyJavaVM() to unload the entire VM.

The VM waits until the main thread is the only user thread before it actually unloads. User threads include both Java threads and attached native threads. This restriction exists because a Java thread or attached native thread may be holding system resources, such as locks, windows, and so on. The VM cannot automatically free these resources. By restricting the main thread to be the only running thread when the VM is unloaded, the burden of releasing system resources held by arbitrary threads is on the programmer."


Is it possible resources are being held and the VM is waiting to unload? Because of the wait, System Preferences appears to freeze?


Rob


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Screen Saver Question (From: Paul Murray <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.