Re: limits of objects
Re: limits of objects
- Subject: Re: limits of objects
- From: Jörn Salewski <email@hidden>
- Date: Fri, 22 Aug 2003 14:01:19 +0200
Once I had the same problem ("solved" at that time by postponing the use of
regexs in my code). Now, I used the opportunity of this thread to have a
closer look at the AGRegex code and found the culprit (obviously bad memory
management as pointed out before):
The description of AGRegexMatch is lying about what it really contains.
Every match creates a COPY of the original string to search in! That means
that if you expect ca. 2500 matches in a 280k file, you end up with 2500 *
280k = 700000k = about 680 MB of memory usage.
If one doesn't alter the original string while working on the resulting
matches, it should be fairly safe to change the copy to retain in the init
method of AGRegexMatch and recompile the framework. Maybe I shall try it
sometimes when I come back to implement regexs in my app.
JS
am 21.08.2003 0:54 Uhr schrieb Ben Dougall unter email@hidden:
>
hiyer,
>
>
i've used a regular expression framework and applied a regex pattern to
>
an NSString. when saved as a text file, this string i'm applying the
>
pattern to is about 280k. looking at the text, bearing in mind the
>
pattern i'm using, i'd say they'll be about 2500 matches. a single
>
match looks something like this when output using it's description
>
method:
>
>
<CFArray 0x1485ca0 [0xa01303fc]>{type = mutable-small, count = 1,
>
values = (
>
0 : <AGRegexMatch: 0x1474150> {
>
0 {0, 53} 19 0 obj
>
1 {0, 2} 19
>
2 {3, 1} 0
>
>
so a match looks like it's basically made up of a small array with a
>
few strings and a few ranges.
>
>
when applied to the 280k text the memory (viewing in process viewer)
>
goes up and up, then the drive start thrashing and after some time i
>
decide to force quit, by which time my app is in red in the force quit
>
window.
>
>
here's the code that sets up the regex and performs it:
>
>
AGRegex *regex;
>
regex = [[AGRegex alloc] initWithPattern:@"(\\d+) +(\\d+) +obj"];
>
NSArray *all = [regex findAllInString:pdfAscii];
>
>
am i doing something wrong, or am i expecting too much? i was hoping to
>
parse far larger files than this one that's sending my computer into a
>
spin.
>
>
i'm probably going to do what i'm trying to do above a completely
>
different way now for other reasons, but i do find it a concern that
>
not such a large number of objects would seem to be over a fairly small
>
limit. i'm hoping i'm just doing something wrong. is that the case?
>
>
thanks, ben.
>
_______________________________________________
>
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.
_______________________________________________
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.