Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
so, once the file has been read into memory; if you change the file is the msync called automatically, or periodically? (i guess automatically with an autosave feature, and periodically with no autosave?).
If you mmap (not "read") a file to memory and alter it, no one is going write (page out) the stuff on disk for you. You have to do this yourself by calling msync. (Not sure about what happens when you do munmap though.)

However, there is also no guarantee that it ISN'T going to be written out either. If free and inactive RAM runs low and another process (or even your own process) needs more pages, the VM (Virtual Memory) system will "steal" a page that hasn't been used for a while, even if it is in use. In this case the system will do a page out for you.


..because the page out information is not correct :D horrah i understand.
The page out information is correct, I believe. It counts the number of times the OS has written a page to either the swap files or to another file. You just have to understand that having a page out does not necessarily mean that you have run out of free RAM.


believe it or not i was actually going to suggest the size being 4KB. i had a feeling ;) i guess this cant really be altered from program to program - its more of an OS thing? smaller is better i guess for RAM anyway.
It is more of a hardware thing and (often) not for the OS to decide.

Having small pages means that you can model the working set of a process more closely and this saves RAM. (Consider a page where only the first word is used and the rest is never touched.)
http://en.wikipedia.org/wiki/Working_set

However the OS keeps internal tables to track each page in RAM. Each page needs a number of bytes in wired memory to keep track of what the page is used for. This overhead becomes percentually smaller if you use larger pages.

Also if a process uses a large amount of RAM, the number of page faults will increase if the pages are very small. Also, the internal hardware mechanisms that translate virtual addresses to physical addresses can often cache a finite amount of pages. This will also benefit having large pages.

Servers that can host large processes (database servers that access several gigabytes of RAM) can often use "huge pages" which can be megabytes in size to avoid having so many pages to keep track of.

So the page size is more of a tradeoff.
 
If you mmap (not "read") a file to memory and alter it, no one is going write (page out) the stuff on disk for you. You have to do this yourself by calling msync. (Not sure about what happens when you do munmap though.)
haha ok just making sure. you wouldnt want all this extra crap being written all the time automatically, so that makes sense.

However, there is also no guarantee that it ISN'T going to be written out either. If free and inactive RAM runs low and another process (or even your own process) needs more pages, the VM (Virtual Memory) system will "steal" a page that hasn't been used for a while, even if it is in use. In this case the system will do a page out for you.
even if it is active RAM? well that is highly inefficient!! i can understand that it might steal active RAM if there is no inactive RAM, but if there is inactive RAM available and it still steals the active RAM... thats just silly.


The page out information is correct, I believe. It counts the number of times the OS has written a page to either the swap files or to another file. You just have to understand that having a page out does not necessarily mean that you have run out of free RAM.
page outs are included even when you msync, ok yea that makes sense sorry for the confusion. are there any other types of memory swapping/page outs?


It is more of a hardware thing and (often) not for the OS to decide.
really? interesting. one can choose the sector size on HDDs but not on RAM? probably for good reasons though.

Having small pages means that you can model the working set of a process more closely and this saves RAM. (Consider a page where only the first word is used and the rest is never touched.)
http://en.wikipedia.org/wiki/Working_set
how informative. does it refer to "memory" as the total memory? or just "physical" memory?

if its just physical memory they are referring to - so the basic concept of that if you have 3 programs that take 2GB of RAM each, and you only have 2GB of memory total - when you want to use a different application then the memory is taken from "physical memory" into "virtual memory"?

or does it include total memory? very n00bish i know :p

However the OS keeps internal tables to track each page in RAM. Each page needs a number of bytes in wired memory to keep track of what the page is used for. This overhead becomes percentually smaller if you use larger pages.
geez so there would be a nice portion in wired memory. that makes perfect sense!!

Also if a process uses a large amount of RAM, the number of page faults will increase if the pages are very small. Also, the internal hardware mechanisms that translate virtual addresses to physical addresses can often cache a finite amount of pages. This will also benefit having large pages.
true, but larger pages can also have their disadvantages especially if you do lots of small read/write stuff.

Servers that can host large processes (database servers that access several gigabytes of RAM) can often use "huge pages" which can be megabytes in size to avoid having so many pages to keep track of.
i guess they would have the resources to allocate these 'memory databases' though.

So the page size is more of a tradeoff.
depends what you need it for, even though we cannot change the size of it by the sounds of it haha.

thanks again for the reply (sorry my reply is late, i needed sleep!)

LOL...I don't get it again.........:confused:

what part are you confused with?
 
haha ok just making sure. you wouldnt want all this extra crap being written all the time automatically, so that makes sense.


even if it is active RAM? well that is highly inefficient!! i can understand that it might steal active RAM if there is no inactive RAM, but if there is inactive RAM available and it still steals the active RAM... thats just silly.



page outs are included even when you msync, ok yea that makes sense sorry for the confusion. are there any other types of memory swapping/page outs?



really? interesting. one can choose the sector size on HDDs but not on RAM? probably for good reasons though.


how informative. does it refer to "memory" as the total memory? or just "physical" memory?

if its just physical memory they are referring to - so the basic concept of that if you have 3 programs that take 2GB of RAM each, and you only have 2GB of memory total - when you want to use a different application then the memory is taken from "physical memory" into "virtual memory"?

or does it include total memory? very n00bish i know :p


geez so there would be a nice portion in wired memory. that makes perfect sense!!


true, but larger pages can also have their disadvantages especially if you do lots of small read/write stuff.


i guess they would have the resources to allocate these 'memory databases' though.


depends what you need it for, even though we cannot change the size of it by the sounds of it haha.

thanks again for the reply (sorry my reply is late, i needed sleep!)



what part are you confused with?

What is msync

And Is there anyway to turn off inactive RAM?
 
LOL! one cannot simply turn on or off these type of things.

all of these things are managed by the OS, and not via each application (the application may have access to a call that refers to these operations though).

Right, but I was just saying there probably is a way. Computers aren't magic. If some clever coder were able to tell the OS to stop using certain things it would, but it would probably cease to function.
 
What is msync

Please try google! :) (sorry, but just read the first hit)

And Is there anyway to turn off inactive RAM?

Why on earth would you want to? inactive RAM is as available to use as free RAM. With the added benefit that if you SHOULD want the data that is cached in inactive RAM you have saved a disk I/O.

If you are disturbed by a large blue chunk in the pie chart in Activity Monitor, you can click on the blue square on the left and change its color to green. Fixed!
 
even if it is active RAM? well that is highly inefficient!! i can understand that it might steal active RAM if there is no inactive RAM, but if there is inactive RAM available and it still steals the active RAM... thats just silly.

I'm not sure about the exact policies used in OS X but I think the system will certainly prefer using an inactive page over stealing active pages.

However, it is not uncommon to have a policy that periodically scans active memory and makes it inactive. Just as the hardware maintains a bit that is set whenever a process writes a page, another bit is set whenever a page is read. By scanning active RAM periodically you can detect RAM that hasn't been used since the last scan. Some of these pages can be made inactive. If the process SHOULD access that page, it will have a soft page fault and the page will be brought back to the process again. Just a couple of instructions and no disk access needed.

Provided of course that the user hasn't installed one of these programs that sabotage the inactive list by turning that RAM to free green RAM :)

The point of this stealing is to trim unused RAM from the process so that it doesn't use more RAM than needed (it's theoretical working set). If the inactive list (and free list) should shrink too low, the system have no good idea where to steal RAM anymore. So the system tries to maintain a balance on the free and inactive list sizes.


how informative. does it refer to "memory" as the total memory? or just "physical" memory?

if its just physical memory they are referring to - so the basic concept of that if you have 3 programs that take 2GB of RAM each, and you only have 2GB of memory total - when you want to use a different application then the memory is taken from "physical memory" into "virtual memory"?

I don't think OS X kicks entire processes out of memory. OpenVMS can.
Please disregard from that part in the wikipedia article.

The notion of "working set" is useful to understand that even if a process has mapped half the world into it virtual address space, he amount of memory it actually accesses during a time period is often a small portion. If we could correctly identify WHAT portion we only need to allocate RAM for that subset of virtual memory. Figuring this out is central to a good virtual memory manager.
 
So....much.....nerdiness.....can't....see....



I would have just answered "The terrorists win." and left it at that. :D
 
I'm not sure about the exact policies used in OS X but I think the system will certainly prefer using an inactive page over stealing active pages.
ahh, yes it would make a lot of sense then. stealing the active pages wouldnt be very efficient at all.

However, it is not uncommon to have a policy that periodically scans active memory and makes it inactive. Just as the hardware maintains a bit that is set whenever a process writes a page, another bit is set whenever a page is read. By scanning active RAM periodically you can detect RAM that hasn't been used since the last scan. Some of these pages can be made inactive. If the process SHOULD access that page, it will have a soft page fault and the page will be brought back to the process again. Just a couple of instructions and no disk access needed.
so the "status" of the RAM is managed by the OS aswell? is it possible for an application to set the status of its RAM, this would seem more efficient to me as the applications know what they are using, the OS would just be scanning randomly to check a bit for the last read/write time no?

Provided of course that the user hasn't installed one of these programs that sabotage the inactive list by turning that RAM to free green RAM :)
i actually have one of those! it pretty much just gives you free memory. i guess it marks all the memory as free.

The point of this stealing is to trim unused RAM from the process so that it doesn't use more RAM than needed (it's theoretical working set). If the inactive list (and free list) should shrink too low, the system have no good idea where to steal RAM anymore. So the system tries to maintain a balance on the free and inactive list sizes.
tries but doesnt succeed ha! i regularly see "10mb" in my free RAM. not that it bothers me as i know inactive RAM is still there waiting to be used.


I don't think OS X kicks entire processes out of memory. OpenVMS can.
Please disregard from that part in the wikipedia article.
never heard of this OpenVMS, sounds nasty ;)

with virtual programs that use up GB of memory, sometimes my computer will quit the application. do you think that it could be from that? there could be every possibility i guess.

The notion of "working set" is useful to understand that even if a process has mapped half the world into it virtual address space, he amount of memory it actually accesses during a time period is often a small portion. If we could correctly identify WHAT portion we only need to allocate RAM for that subset of virtual memory. Figuring this out is central to a good virtual memory manager.
it seems a really important topic, especially for the server class of computers. the algorithms to sort these would be unimaginable.

the working set idea seems pretty useful, once you can find out what memory is being used the most.

if you looked in the entire memory contents of a computer there would be hundreds/thousands of cases where there are repeated contents of memory. can the "virtual memory" on the computer can sense that there are repeats and direct each process to this one reference? or will it create many "links" (forget the real word for it sorry).

Also meant to ask a few posts back what your occupation is and how you know so much.

Ill be referring back to this thread for years :)
So....much.....nerdiness.....can't....see....

I would have just answered "The terrorists win." and left it at that. :D
do you understand it? there will be an assignment on it later today!

This is probbably the best thread on memory management under OS X I've ever seen. :D
im excited to be a part of it! as nerdy as that sounds.... how do you find it?
 
wow... really very informative here.
thanks everyone for sharing your brain cells :D
 
Please try google! :) (sorry, but just read the first hit)



Why on earth would you want to? inactive RAM is as available to use as free RAM. With the added benefit that if you SHOULD want the data that is cached in inactive RAM you have saved a disk I/O.

If you are disturbed by a large blue chunk in the pie chart in Activity Monitor, you can click on the blue square on the left and change its color to green. Fixed!

I use google for a lot of things but if its something about mac os x I love asking the macrumors community
 
O rly?

Screenshot2009-10-12at84921PM.png


I haven't paged out in forever...

Same here not that I have noticed.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.