HI, I've been trying to do a batch converter for images. The problem
is the memory is not being released properly. When the for ends the
memory is ok, but during the for it continues increasing. I have a
function with a for loop:
for(count=0;count<cant;count++)
{
path=[datos objectAtIndex:count];
save_name=[NSString stringWithFormat:
@"image_%04d.jpg",count+1];
output=[[batch_outdir stringValue]
stringByAppendingPathComponent:save_name];
[self convert:path path_out:output format:NSJPEGFileType quality:
0.3];
}
and then the conversion function
-(void)convert:(NSString*)path_in path_out:(NSString*)path_out format:
(NSBitmapImageFileType)type quality:(float)q
{
NSDictionary *d=[NSDictionary dictionaryWithObject:
[NSNumber numberWithFloat:q]
forKey:NSImageCompressionFactor];
NSImage *tmp_img;
NSBitmapImageRep *b;
NSData *data;
tmp_img=[[NSImage alloc] initWithContentsOfFile:path_in];
b=[NSBitmapImageRep imageRepWithData:[tmp_img TIFFRepresentation]];
[tmp_img release];
data=[b representationUsingType:tipo properties:d];
[data writeToFile:path_out atomically:TRUE];
}
David Phillip Oster - 21 Sep 2007 16:12 GMT
> HI, I've been trying to do a batch converter for images. The problem
> is the memory is not being released properly. When the for ends the
> memory is ok, but during the for it continues increasing. I have a
> function with a for loop:
> for(count=0;count<cant;count++)
> {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> path=[datos objectAtIndex:count];
> save_name=[NSString stringWithFormat:
[quoted text clipped - 3 lines]
> [self convert:path path_out:output format:NSJPEGFileType quality:
> 0.3];
[pool release];
> }
Michael Ash - 21 Sep 2007 16:15 GMT
> HI, I've been trying to do a batch converter for images. The problem
> is the memory is not being released properly. When the for ends the
> memory is ok, but during the for it continues increasing. I have a
> function with a for loop:
Please learn to crosspost:
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
The way you posted now, I saw your message twice, and had to mark it as
read twice. Crossposting correctly will make it so I only see it once. Of
course the best way is to only post to a single group. This question is
off-topic for comp.lang.objective-c anyway, so it doesn't really belong
there.

Signature
Michael Ash
Rogue Amoeba Software