• 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
leek in componentsSeparatedByString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

leek in componentsSeparatedByString


  • Subject: leek in componentsSeparatedByString
  • From: David Burris <email@hidden>
  • Date: Mon, 26 Aug 2002 10:35:24 -0400

*This message was transferred with a trial version of CommuniGate(tm) Pro*
I am trying to create a function that will read through text files, using the componentsSeparatedByString function to split the lines into words. however when i run my test code on a large (68,000 lines) file, i notice a fair bit of memory leak from the componentsSeparatedByString call. here is my test code. If i try to release the 'words' in the loop then i get a signal 10 (SIGBUS) error when i run it.

Any suggestions would be greatly appreciated.



#import <Foundation/Foundation.h>
#import <tester.h>

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

tester * c1 = [tester alloc];

[c1 infile:@"hackdemomedow2.rib" outfile:@"temp.rib"];

[pool release];
return 0;
}



#import "tester.h"
@implementation tester

- (void)infile:(NSString *)infile outfile:(NSString *)outfile {
NSString* firstWord;
//NSMutableArray* words;// = [[[NSMutableArray alloc] init] autorelease];

char* infilename = [infile cString];
char* outfilename = [outfile cString];
char temp[1001];
FILE* inRIB;
FILE* outRIB;
char* outf;
inRIB = fopen(infilename, "r");
outRIB = fopen(outfilename, "w");

NSLog(@"infilename = %@", [NSString stringWithCString:infilename]);
NSLog(@"outfilename = %@", [NSString stringWithCString:outfilename]);

while (fgets(temp, 1000, inRIB) != NULL){

NSString* currentline = [[NSString stringWithCString:temp]autorelease];
NSMutableArray* words = [[currentline componentsSeparatedByString:@" "]mutableCopy];

//[words release];
//words = nil;

[currentline release];
//currentline = nil;

//free(temp);
}

fclose(inRIB);
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Leak in NSFont (10.2) or am I missing something?
      • From: Charles Bennett <email@hidden>
  • Prev by Date: Re: Re-open last saved document
  • Next by Date: QT movie info
  • Previous by thread: Re: Re-open last saved document
  • Next by thread: Leak in NSFont (10.2) or am I missing something?
  • Index(es):
    • Date
    • Thread