Hey so recently I was trying to get the Page Size down for our webpage in safari. And in the process I found that most of it was because of one svg image.
Here is the image: https://d6d4ismr40iw.cloudfront.net/img/EventBlur_verybig.svg
If you open this image in safari and look at the vm tracker attached to the thread on mac you will see this:
It shows dirty size of over 1.15GB. My understanding of dirty size is that its the memory being used by the process actively that cannot be recreated by the os. So basically it really is memory that is critical and doing real work in application space.
If you open this image in chrome and look at that thread you see that the dirty size is very small:
I have also noted that inside this svg file there is a filter, whose dimensions directly affect how much size is taken up.
<defs> <filter id="filter2_dddf" x="0" y="0" width="2400.00" height="2400.00" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB" >
If I change the width and height here it correlates directly to memory usage. (These I read off of the timeline tab in safari dev tools and not from the Instruments profiles)
Filtersize | Page Size(mb) ------------------------------------ 300 | 90 600 | 150 1200 | 400 2400 | 900
So, why does safari take so much more memory?! I have the code for webkit on my local and I have tried to find the implementation of these tags in it. I don't see anything obviously wrong in there but Im no C++ expert.
So I compiled webkit in the hopes of stepping through as it renders that svg. It looks like safari keeps re-rendering this thing. I can see in the memory meter on the left that it drops to low values sometimes and then comes back up. Im guessing chrome just doesn't do that. However, I don't know how to confirm that aside from compiling chromium as well (im not too enthusiastic about that). Ill just try to figure out why this function is running again.
So, now in xcode I can see a memory graph. But I don't know how to make sense of this. I need to know what part of this is due to the image and what is just always there.
Those allocations don't really add up to the usage with was like 80mb. The problem should be in mallocs only right? Can't be in a dylib I hope.