TITLE
    WebObjects 4: NSLog and Slow NT Application Response Time
Article ID:
Created:
Modified:
70081
6/22/99
1/24/00

TOPIC

    The workaround described in this article has been included in WebObjects 4.0.1 Patch 2 and subsequent patches. Please see the WebObjects Current Patch List, TIL article 70037 , for information on the most current patches for WebObjects and Enterprise Objects Framework. This obsolete article is provided here as a convenience to our customers who have not yet upgraded to the most current patch level.


DISCUSSION

    Q: I've upgraded my Windows NT installation from WebObjects 4.0 to WebObjects 4.0.1, and some of my applications are much slower than they were on 4.0. How can I fix this problem?

    A: There is a known problem with NSLog in WebObjects 4.0.1. In some cases, NSLog statements can take as much as thirty seconds to execute. To see if you are encountering this problem, try adding this code (or its Java equivalent) to your application's main function:

    int index;
    for (index=0; index<100;index++)
    NSLog(@"HELLO");

    If this slows your application down significantly, you are most likely encountering this bug. Apple is actively working on a patch for this problem; more information will be posted here when the patch is available. Until the patch is ready, a workaround is to manually replace NSLog() with an equivalent function that does not experience these delays. For example, incorporate the following code into main:

    extern void _NSSetLogCStringFunction(void(*)(const char *, unsigned, BOOL));

    static void _GarbageFreeLogCString(const char *message, unsigned length,
    BOOL withSyslogBanner) {
    fprintf(stderr, "%s\n", message);
    }


    int main (int argc, const char *argv[]) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int exitCode;


    setbuf(stderr, NULL);
    _NSSetLogCStringFunction(_GarbageFreeLogCString);
    exitCode = WOApplicationMain(@"Application", argc, argv);
    [pool release];
    return exitCode;
    }

    Be aware that this code references private APIs; this is an unsupported workaround and users should use these instructions at their own risk. Apple will not guarantee or provide support for this procedure. In addition, this function does not contain any Windows I/O code and will not give any output if run from a DOS shell.


Document Information
Product Area: WebObjects
Category: WebObjects 4
Sub Category: Development
Keywords:

Copyright © 2000 Apple Computer, Inc. All rights reserved.