Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Find and close last opened tab in Safari
Finding and opening the last open tab in Safari, is usually straightforward; just look in the user interface. However, that's not an option, because every time the browser is started, it opens every previous window and tab, and begins loading up infinite memory, 150+ GBs, until the system runs out. The quick solution would be to find the caches and delete them all. Although, I want to keep my tabs.
The infinite memory bug is usually a result of clicking on the tab overview; that makes the browser attempt to load in every tab and display them. A quick restart brings the browser back to its previous state. This time, however, the issue started occuring as I opened some webpage. Thus I hope that by deleting that webpage from Safari's cached open pages, I can restore the browser to its previous, working, state.
Where do I find this cache, and how do I navigate it? I have found these files:
/Users/<current>/Library/Saved Application State/com.apple.Safari.savedState
- data.data
- windows.plist
The property list file seems to contain a list of the application's last known window and tab state, amongst other unknown data. If this is the right place to go, how do I locate the offending tab/webpage and delete it from the entry without causing more issues?
1 answer
Warning: this will result in the entire window the tab was located in, to be deleted
Warning: windows.plist
is invalid without its data.data
file. Back up both before proceeding.
Skip the first two steps if you remember the name of the tab.
-
Find and inspect
~/Library/Safari/History.db
A suitable application is DB4S, which can be installed with
brew install --cask db-browser-for-sqlite
-
Inspect
history_visits
and sort byvisit_time
to find the latest entry. Usetitle
in the next step. -
Open
~/Library/Saved Application State/com.apple.Safari.savedState/windows.plist
-
Search for the page title from the previous step. It's the value for an
NSTitle
key. Once found, delete the enclosing dict. -
Start Safari. Every window except the one with the latest tab should now open. The window is likely lost because
data.data
now has a mismatch with entries for that window inwindows.plist
.
The window may be recoverable by using the application menu to choose to open the last closed window. I made too many mistakes in the process and lost this chance.
0 comment threads