Skip navigation.
 
mlRe: Cache Class review (low priority)
FROM : Jens Alfke
DATE : Fri May 02 20:03:22 2008

On 2 May '08, at 9:32 AM, Western Botanicals wrote:

> The reason I put the AutoReleasePools in there is because I am 
> getting these errors in the output. So if you can help me find what 
> is wrong that would be great. Every time I create a Date or Timer 
> object, I get one or both of these:


You're probably running this as a GUI-less tool process, i.e. directly 
calling your code from main(). If you do this, you need to create a 
top-level autorelease pool before calling into your code. In general, 
main() looks like:
   int main( int argc, const char **argv ) {
       NSAutoreleasePool *pool = [NSAutoreleasePool new];
       int result = 0;
       // your program code goes here
       [pool drain];
       return result;
   }

In a GUI application (or even a runloop-based tool) you don't have to 
worry about this, because NSRunLoop makes sure to create an 
autorelease pool whenever it calls into application code.

Speaking of runloops, your test code needs to idle the runloop in 
between its tests, to give the timer a chance to expire entries. You 
currently have some (commented-out) usleep calls, but those won't 
work, because the runloop is on your thread and has to be explicitly 
given time to run. You can replace those with
   [[NSRunLoop currentRunLoop] runUntilDate: [NSDate 
dateWithTimeIntervalSinceNow: 0.25];

—Jens

Related mailsAuthorDate
mlCache Class review (low priority) Western Botanicals Apr 30, 15:50
mlRe: Cache Class review (low priority) Jean-Daniel Dupas Apr 30, 16:44
mlRe: Cache Class review (low priority) Jens Alfke Apr 30, 17:08
mlRe: Cache Class review (low priority) Western Botanicals May 1, 00:14
mlRe: Cache Class review (low priority) Jens Alfke May 1, 04:30
mlRe: Cache Class review (low priority) Western Botanicals May 2, 01:49
mlRe: Cache Class review (low priority) Jens Alfke May 2, 06:58
mlRe: Cache Class review (low priority) Gregory Weston May 2, 13:37
mlRe: Cache Class review (low priority) Jens Alfke May 2, 17:22
mlRe: Cache Class review (low priority) Western Botanicals May 2, 18:32
mlRe: Cache Class review (low priority) Jens Alfke May 2, 20:03
mlRe: Cache Class review (low priority) Uli Kusterer May 2, 22:29
mlRe: Cache Class review (low priority) Chris Hanson May 3, 04:24