Re: real verses Virtual memory
Re: real verses Virtual memory
- Subject: Re: real verses Virtual memory
- From: Jens Alfke <email@hidden>
- Date: Sat, 10 Oct 2009 12:33:32 -0700
A couple of points…
[1] Yes, it is possible to allocate "wired" memory that is forced to
stay in physical RAM and never be paged to disk. But this ability is
pretty much used only by low-level software like kernel extensions,
device drivers, and real-time audio processors. These are things that
either interact with memory below the level of the VM system, or that
will fail if a memory access has to wait for disk I/O.
It's generally pretty bad for other software to use wired memory,
because it makes that RAM unavailable for any other process on the
system. In effect, it is slowing down every other process, to benefit
itself. You really don't want to do this. The OS kernel is very highly
tuned to balance the needs of all running processes.
[2] File-system activity is not the same thing as disk I/O. There is a
lot of caching going on (in fact caching and virtual memory are just
two aspects of the same subsystem). Multiple reads of the same file
are not going to hit the disk at all because the file should still be
in cache. Writes will hit the disk, but often not immediately.
[3] Unless the OS is really low on available RAM, or you're allocating
huge amounts of memory, your app is not going to cause VM paging. In
fact, if your app does stuff every 20 seconds, it's not going to get
paged out to disk. Instead, other processes will be paged out to make
room, if necessary. The kernel tries to keep the most recently used
memory in RAM.
[4] The disk I/O you're seeing is almost certainly due to CFNetwork's
caching and cookie mechanisms. You probably don't want to turn off
cookies if the site you're accessing uses any type of login or
persistent state. In any case, the cookies are mostly just going to be
read from disk, not incurring I/O. Turning off caching will increase
the amount of network activity and server-side time, because the
server will have to send the full page to you every time even if it
hasn't changed. I don't recommend that. Many large websites will ban
your IP address if they find you repetitively fetching pages like this.
[5] You haven't described any functionality that requires using a
WebView. All you need, I think, is NSURLConnection to fetch the
contents of the page. If you need to parse the HTML, you can use
NSXMLDocument for that — it supports a query format called XPath that
makes it very easy to find specific data in an HTML page.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden