An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Topic Options
#36903 - 11/01/15 01:31 AM Swap file oddity
artie505 Online


Registered: 08/04/09
The only other time I've run across this was in a post by MMT3 a coupl'a years ago.

As you can see in this screenshot, swap file 5 was shows a creation time earlier than those of files 1, 2, 3, and 4.

Can anybody think of a possible explanation?

Thanks.
_________________________
The new Great Equalizer is the SEND button.

In Memory Of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire

Top
#36907 - 11/01/15 05:41 AM Re: Swap file oddity [Re: artie505]
joemikeb Offline

Moderator

Registered: 08/04/09
Loc: Fort Worth, Texas
Look at what you posted. Those are date modified NOT dated created. That simply means the other swap files have had some data changed since the data in 5 was changed.

My surprise is your having swap files at all much less 5 swap files. On my Mac mini with 16GB of memory the Mamory compression and other memory management improvements in Yosemitie and El Capitan I seldom have swap files any more.
_________________________
joemikeb • moderator

Top
#36914 - 11/02/15 12:39 AM Re: Swap file oddity [Re: joemikeb]
artie505 Online


Registered: 08/04/09
I noticed that my screenshot displayed only modification dates after I'd already restarted and cleared the excess files, uploaded the screenshot, and posted. frown

I reeeally spaced and didn't think to change my post, though, because any time and anywhere I've ever looked on my deuced Mac(hina), every file that displays both creation and modification dates shows them as being identical, and I proceeded on the assumption that it's universal in OS X (which, on reflection, is a ridiculous notion) and that the two time stamps would have been identical had I looked. (Is there a pref that governs that, and is there a Terminal command I can run that will set a pref to show both dates in all list view windows so I don't have to do a command-J every time I open one?)

And in a different vein, do swap files actually get modified? For no particular reason other than a very rudimentary understanding of their functionality, I've always assumed that they're created in their final form.

And if they do, is it at all likely that they'd get modified in order (which, of course, begs the question)?

My MBP is maxed out with 8 GB of RAM, and I never see swap files other than when I'm editing music files, so this was a real eye-opener, because all I was doing when the files were created was trying to view some web pages in Safari, and either they, it, or both were being very recalcitrant. (Safari crashed twice.)
_________________________
The new Great Equalizer is the SEND button.

In Memory Of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire

Top
#36923 - 11/02/15 10:56 AM Re: Swap file oddity [Re: artie505]
joemikeb Offline

Moderator

Registered: 08/04/09
Loc: Fort Worth, Texas
Assuming OS X 10.10 (Yosemite) or 10.11 (El Czpitan) swap files are created when ALL of following conditions exist...
  • an app requests additional RAM
  • all of the existing RAM is either in wired or active status
  • no additional memory compression is possible
  • no application code can be erased from memory
  • there is data in memory that has been created or modified and would be lost if it were overwritten
When all those conditions occur data segments will be paged out to a swap file in 8 KB pages. The pages to be paged are chosen on the basis of a least recently read and least frequently used algorithm. NOTE: swap files contain ONLY data but that includes dynamic data elements used in code. Executable code can always be reread from the applliction files and does not need to be written to a swap file — in fact that would only serve to slow program execution.

Data in swap files can be "paged" back and forth into RAM. In versions of OS X prior to Yosemite swap files were created as a fixed file size and additional swap files were created to meet the maximum demand for swap files. While the contents of a given swap file could be and frequently was modified, perhaps by multiple tasks no effort was made to erase the contents of a given swapfile but if the data was no longer linked to an active task it could be and was simply overwritten. Erasing the data is an unnecessary waste of CPU cycles. Data was written to the swap files in numerical order starting with the first swapfile that had inactive contents.

Thanks to memory compression and other memory management improvements in Yosemite and El Capitan I encounter so little swap file activity that I am unable to verify whether or not swap files are managed the same way as in previous OS X versions but I would expect that to be the case. In Yosemite and El Capitan...
  • From a logical conceptual viewpoint Virtual Memory. Is largely unchanged, but at the physical implementation level there are major changes and improvements.
  • virtual memory used by an app still includes the actual application file in the /Applications folder, preference files, data files opened by the app, and swap files (if any) all of which are "mapped" into the application's virtual memory space
  • any code or data read by the application counts as a page in
  • anything written to an output file or a swap file is counted as a page out
  • it is in the implementation of swap files and the use of compressed RAM memory for at least a portion of the swap file space where the big change has taken place.
  • The only really useful measure of whether you have enough RAM in your Mac is memory pressure
_________________________
joemikeb • moderator

Top
#36936 - 11/02/15 10:34 PM Re: Swap file oddity [Re: joemikeb]
artie505 Online


Registered: 08/04/09
That reads like it's the beginnings of your new Virtual Memory website. wink

Thanks for the most informative and understandable swap file/virtual memory post I've ever read; it clarifies the subject immensely! smile

OK, then, it sounds like the time stamps in my screenshot should be an accurate reflection of the way things actually happened, and we'll never know if I really experienced an oddity (similar to MMT3's) until the next time the same thing happens. tongue
_________________________
The new Great Equalizer is the SEND button.

In Memory Of Harv: Those who can make you believe absurdities can make you commit atrocities. ~Voltaire

Top

Moderator:  alternaut, dkmarsh, joemikeb