• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times


  • Subject: Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times
  • From: Kane Dijkman <email@hidden>
  • Date: Wed, 30 Mar 2005 23:22:01 -0800

Thanks for the first message and for the follow up to make sure I got it right.

It worked great! I tried a pool but it was around the outside of the loop. Never thought to put it on the inside. Learned something new.

It works without crashing now, and works a lot faster.

Smiles,
Kane


On Mar 30, 2005, at 9:43 PM, Daniel DeCovnick wrote:

Just as a followup, in case my last sentence wasn't clear, it should look like this:
int i;
for (i = 0; i < 500000; i++)
{
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
NSDate *date = [NSDate dateWithNaturalLanguageString:@"12/14/04"];
NSLog(@"%d", i);
[p release];
}
-Dan



On Mar 31, 2005, at 12:08 AM, Daniel DeCovnick wrote:

Yeah, that's the issue. Just put NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; at the beginning (inside) of the loop, and a [p release]; at the end of the iteration of the loop.

-Daniel DeCovnick
danhd123 at mac dot com
Softyards Software
http://www.softyards.com

On Mar 30, 2005, at 11:59 PM, Charilaos Skiadas wrote:

I didn't even wait that long, it was running ridiculously slow in my comp already after 25000 runs. You realize none of these objects get deallocated while you are in this loop? This amounts to 100.000 NSDate objects sitting around in memory....
On Mar 30, 2005, at 10:32 PM, Kane Dijkman wrote:


Hey Folks,

I am working on a project where I have to load up a bunch of information categorized by dates. The dates are in a natural language format "mm/dd/yyyy" and need to be turned into NSDate objects so I can work with them.

The number of items that are being loaded is rather large. Easily Half a million plus.

When I run the program after about 100,000
NSDate * thisDate = [NSDate dateWithNaturalLanguageString:theDate];
the app goes boom and I get an EXC_BAD_ACCESS error.

I thought this might have been from bad memory management (it still might be, as I am *very* new to cocoa development) so I created a simple test app with a button that run this function.

@implementation test


- (IBAction)run:(id)sender
{
int i;
for (i=0; i<500000; i++)
{
NSDate * thisDate = [NSDate dateWithNaturalLanguageString:@"12/14/2004"];
NSLog(@"%d", i);
}
}
@end


After running through about 100,000 of these (give or take) I get the exact same error.

My questions are:

Given the error is an EXC_BAD_ACCESS error am I doing something wrong memory management wise?

If not, any idea what is causing this?

And more to the point... any ideas on how I can fix this? Or how I can work around it?

Thanks Much,
Kane

Haris

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden



------------------------------------------------------------------------ ------------
Insanity in individuals is something rare - but in groups, parties,
nations and epochs, it is the rule.
--Friedrich Nietzsche


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Insetting a complex NSBezierPath shape? (From: Keith Blount <email@hidden>)
 >NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times (From: Kane Dijkman <email@hidden>)
 >Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times (From: Charilaos Skiadas <email@hidden>)
 >Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times (From: Daniel DeCovnick <email@hidden>)
 >Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times (From: Daniel DeCovnick <email@hidden>)

  • Prev by Date: Adding custom NSView to cell in NSTableView
  • Next by Date: Re: class within an interface?
  • Previous by thread: Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times
  • Next by thread: Re: NSDate dateWithNaturalLanguageString goes BOOM! after being called 100, 000+ times
  • Index(es):
    • Date
    • Thread