• 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
Re: NSImage and F_NOCACHE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage and F_NOCACHE


  • Subject: Re: NSImage and F_NOCACHE
  • From: Alexander Cohen <email@hidden>
  • Date: Wed, 4 Oct 2006 16:14:11 -0400


On 4-Oct-06, at 2:38 PM, Matt Neuburg wrote:

On Wed, 4 Oct 2006 11:48:13 -0400, Alexander Cohen
<email@hidden> said:
Hi,

Im using F_NOCACHE with fcntl just before loading the file up as an
NSImage so the data does not get cached and memory stays down. Im
doing this because im converting thousands of images ( eps, tif, psd,
pdf, anything... ). Thing is, memory never comes down. I though it
might be a memory leak or something so i brought the code down to this:



int err = 0; int fd = open( [self cString], O_RDWR ); err = fcntl(fd, F_NOCACHE, 1); NSImage* img = [[NSImage alloc] initWithContentsOfFile:self]; [img release]; img = nil;

That's sort of like filling your car with gas and then driving away in a
*different* car and then being surprised that it runs out of gas right away.
Try it like this:


NSFileHandle* fh = [NSFileHandle fileHandleForReadingAtPath:myFile];
int fd = [fh fileDescriptor];
fcntl(fd, F_NOCACHE, 1);
fcntl(fd, F_RDAHEAD, 1);
NSData* pictureData = [fh readDataToEndOfFile];
[fh closeFile];

Its funny, im using your exact code modified like the following but memory still goes way up.


NSAutoreleasePool*	pool = [[NSAutoreleasePool alloc] init];

NSFileHandle* fh = [NSFileHandle fileHandleForReadingAtPath:myFile];
int fd = [fh fileDescriptor];
fcntl(fd, F_NOCACHE, 1);
fcntl(fd, F_RDAHEAD, 1);
NSData* pictureData = [fh readDataToEndOfFile];
[fh closeFile];


NSImage*	img = [[NSImage alloc] initWithData: pictureData];
[img release];
img = nil;

[pool release];
pool = nil;

Im not sure whats going on.

AC



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: NSImage and F_NOCACHE (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Stopping double clicking of a file
  • Next by Date: Re: Stopping double clicking of a file
  • Previous by thread: Re: NSImage and F_NOCACHE
  • Next by thread: accessibility and iTunes?!?
  • Index(es):
    • Date
    • Thread