turns out the 4gb spike i saw from profiling my book reading app is a security feature from WebKit's JS VM Gigacage, not a leak. 4GB of virtual memory but zero physical RAM.
and the actual real extra problem was apple webkit's back-forward cache holding onto the old caches from previous chapters so i re implemented the reader and started a fresh WkWebView per chapter. that kills the process between chapters, releasing the cache, no accumulation.
this spends about 200ms per chapter load but using a single WkWebView comes with a lot of cache management that i'm not ready for atm, maybe later.
now i got worried about that too because that'd mean moving back and forth between the end of chapter A and the start of chapter B would kill and open processes repeatedly and that doesn't sit well too.
i ever faced something similar when i was learning jdbc in java, the problem was to either use one connection during the server runtime or open and close a connection to the db everytime. that ended with me using a connection pool
similar here i'm thinking of using a pool of WkWebView, about 3 of them, one for the current chapter and the next for the next 2 adjacent chapters.
with this the user won't feel the process spawn per chapter and with 3 WKWebViews in a ring buffer, the adjacent navigation becomes instant. far jumps still spawns, but that happens once a while while reading a book
may learn newer stuff though