Instruments (Leaks) and NSDateFormatter
Posted
by Cal
on Stack Overflow
See other posts from Stack Overflow
or by Cal
Published on 2009-07-13T00:03:57Z
Indexed on
2010/05/29
6:52 UTC
Read the original article
Hit count: 442
When I run my iPhone app with Instruments Leaks and parse a bunch of NSDates using NSDateFormatter my memory goes up about 1mb and stays even though these NSDates should be dealloc'd after the parsing (I just discard them if they aren't new).
I thought the malloc (in my heaviest stack trace below) could become part of the NSDate but I also thought it could be memory that only used during some intermediate step in parsing. Does anyone know which one it is or how to find out?
Also, is there a way to put a breakpoint on NSDate dealloc to see if that memory is really being reclaimed?
Here's what my date formatter looks like for parsing these dates:
df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"EEE, d MMM yyyy H:m:s z"];
Here's the Heaviest Stack trace when the memory bumps up and stays there:
0 libSystem.B.dylib 208.80 Kb malloc
1 libicucore.A.dylib 868.19 Kb icu::ZoneMeta::getSingleCountry(icu::UnicodeString const&, icu::UnicodeString&)
2 libicucore.A.dylib 868.66 Kb icu::ZoneMeta::getSingleCountry(icu::UnicodeString const&, icu::UnicodeString&)
3 libicucore.A.dylib 868.67 Kb icu::ZoneMeta::getSingleCountry(icu::UnicodeString const&, icu::UnicodeString&)
4 libicucore.A.dylib 868.67 Kb icu::DateFormatSymbols::initZoneStringFormat()
5 libicucore.A.dylib 868.67 Kb icu::DateFormatSymbols::getZoneStringFormat() const
6 libicucore.A.dylib 868.67 Kb icu::SimpleDateFormat::subParse(icu::UnicodeString const&, int&, unsigned short, int, signed char, signed char, signed char*, icu::Calendar&) const
7 libicucore.A.dylib 868.67 Kb icu::SimpleDateFormat::parse(icu::UnicodeString const&, icu::Calendar&, icu::ParsePosition&) const
8 libicucore.A.dylib 868.67 Kb icu::DateFormat::parse(icu::UnicodeString const&, icu::ParsePosition&) const
9 libicucore.A.dylib 868.67 Kb udat_parse
10 CoreFoundation 868.67 Kb CFDateFormatterGetAbsoluteTimeFromString
11 CoreFoundation 868.67 Kb CFDateFormatterCreateDateFromString
12 Foundation 868.67 Kb -[NSDateFormatter getObjectValue:forString:range:error:]
13 Foundation 868.75 Kb -[NSDateFormatter getObjectValue:forString:errorDescription:]
14 Foundation 868.75 Kb -[NSDateFormatter dateFromString:]
Thanks!
© Stack Overflow or respective owner