Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-13-2008, 01:39 PM   #1 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default memory leak? help!

Code:
- (NSString *)allLines:(NSString *)searchText {
    NSMutableString *string = [NSMutableString stringWithString:@""];

    for ( int n = 35; n <= 71115; n++ ) {
        if ( [[self.entryList objectAtIndex:n] rangeOfString:searchText].length != 0 ) {
            [string appendString:[self.entryList objectAtIndex:n]];
            [string appendString:@"\n\n"];
        }
    }
		
    return string;
}
I have a txt file parsed into an array of NSString and this function is supposed to return each entire line if the searched text can be found on that line. However, each time I try to search within the program, I get the following error:

Code:
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/chuck/Library/Application Support/iPhone Simulator/User/Applications/6C48ABB8-4FD6-4741-A3AA-536ACF674DE5/My.app/My', process 16561.
Am I forgetting to release an object or perhaps I should be using a pointer where I'm using a variable? If you could help me see what I'm doing wrong here, I'd greatly appreciate it.
chuck is offline   Reply With Quote
Old 08-13-2008, 01:49 PM   #2 (permalink)
Registered Member
 
iamjediknight's Avatar
 
Join Date: Jul 2008
Posts: 111
iamjediknight will become famous soon enough
Default

Just because you get that core dump doesn't mean its a memory issue. I would try to add some NSLog's to figure exactly when your getting the core dump

1. Is is after your checking the length?
2. Is it after you do string appends?
3. Is it right before your return of the method
4. Does it happen at the same point and at the same iteration number of the loop?
5. Or is it happening somewhere else?

Sorry but just by looking at your code nothing jumped out. So I thought I would give a few ideas to try that I would try myself.

scott.
iamjediknight is offline   Reply With Quote
Old 08-13-2008, 02:32 PM   #3 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default

Good point! I had tried that, but not thoroughly enough. Now I found there's something amiss in element 44 of the array, but the rest of the lines are fine. Thanks for pointing me in the right direction!
chuck is offline   Reply With Quote
Old 03-03-2009, 01:00 PM   #4 (permalink)
New Member
 
Join Date: Mar 2009
Location: Sao Paulo, Brazil
Posts: 1
CarlosMelo is on a distinguished road
Thumbs up

Quote:
Originally Posted by chuck View Post
Code:
- (NSString *)allLines:(NSString *)searchText {
    NSMutableString *string = [NSMutableString stringWithString:@""];

    for ( int n = 35; n <= 71115; n++ ) {
        if ( [[self.entryList objectAtIndex:n] rangeOfString:searchText].length != 0 ) {
            [string appendString:[self.entryList objectAtIndex:n]];
            [string appendString:@"\n\n"];
        }
    }
		
    return string;
}
I have a txt file parsed into an array of NSString and this function is supposed to return each entire line if the searched text can be found on that line. However, each time I try to search within the program, I get the following error:

Code:
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/chuck/Library/Application Support/iPhone Simulator/User/Applications/6C48ABB8-4FD6-4741-A3AA-536ACF674DE5/My.app/My', process 16561.
Am I forgetting to release an object or perhaps I should be using a pointer where I'm using a variable? If you could help me see what I'm doing wrong here, I'd greatly appreciate it.

Chuck,

try to use:
return [string copy];
or define your method this way:
- (NSMutableString *)allLinesNSString *)searchText

best regards,

Carlos
CarlosMelo is offline   Reply With Quote
Reply

Bookmarks

Tags
leak, memory

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 315
11 members and 304 guests
chiataytuday, coolman, givensur, guusleijsten, ipodphone, jbro, mediaspree, mottdog, mtl_tech_guy, Punkjumper, vilisei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:21 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0