From e57d875e0abcd95e0fc06690c269e387cd2aa61d Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 29 Jul 2013 09:43:21 -0400 Subject: [PATCH] Try to use a local pool to avoid huge memory consumption --- SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m b/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m index b7cc0144c..6d7e4f78b 100644 --- a/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m +++ b/SOPE/NGCards/versitCardsSaxDriver/VSSaxDriver.m @@ -904,6 +904,7 @@ static NSCharacterSet *whitespaceCharSet = nil; ; be unfolded */ NSMutableString *line; + NSAutoreleasePool *pool; unsigned pos, length; NSRange r; @@ -914,11 +915,18 @@ static NSCharacterSet *whitespaceCharSet = nil; length = [_rawString length]; r = NSMakeRange(0, 0); line = [[NSMutableString alloc] initWithCapacity: 75 + 2]; - + pool = [[NSAutoreleasePool alloc] init]; + for (pos = 0; pos < length; pos++) { unichar c; + if (pos % 10 == 0) + { + RELEASE(pool); + pool = [[NSAutoreleasePool alloc] init]; + } + c = [_rawString characterAtIndex: pos]; if (c == '\r') @@ -1011,6 +1019,9 @@ static NSCharacterSet *whitespaceCharSet = nil; r.length += 1; } } + + RELEASE(pool); + if (r.length > 0) { [self warn: @"Last line of parse string is not properly terminated!"];