title: Techniques for profiling memory in Safari desktop and iOS?
body: <p><strong>Updated 10/21:</strong> Changed title and question in order to possibly get an answer (other than "no").</p>
  
  <p>We're experiencing leaks in Safari (confirmed in Windows and Mac, suspected in iOS).  <s>Are there any Safari extensions that lets one profile JavaScript/DOM memory usage to discover potential leaks?  Better yet, is there any tool that can be used on iOS or in the Apple iOS emulator?</s> What are suggested techniques for discovering what may be causing memory leaks in JavaScript/DOM in Safari?  And does anyone know of ANY way to access memory information for iOS?</p>
  
  <p><strong>Background</strong></p>
  
  <p>We're developing an iOS Safari web application that uses the single-page app paradigm, loading 100s of full-screen images.  We've bypased the normal 6.5 MB iOS Safari image limit by resetting the source for the image tags, but now we're running into what I believe is a memory leak in iOS Safari.  After loading ~250-300 images iOS Safari simply stops loading the images, due to what we suspect is a memory leak.  Not surprising, given that the same leak appears both in Safari for Windows and Safari for Mac - on Windows it is especially bad; for every new full-screen high res image, another 10-15 MB of memory is consumed, if we switch to lower res images it still gobbles up ~5 MB per image.</p>
  
  <p>In Windows we've isolated the leak to the simple act of rendering the image in the browser viewport - we have a carousel of images, and even with zero DOM manipulation, by simply translating (3d) the image through the viewport, memory is allocated and never released.  On Windows, memory consumption can quickly escalate to ~1.5 GB, at which point Safari simply crashes.   On Mac it's not as bad, but memory easily jumps from 100 MB at the start to 500MB and beyond.  In comparison, a Chrome tab/process hosting the same page grows from about 33MB to ~120MB and then stabilizes.</p>
  
  <p><strong>Attempted Workarounds</strong></p>
  
  <p>We have tried deleting the individual image tags and replacing them with the placeholder image rather than resetting them, but this does not seem to alleviate the problem, and also causes performance problems, presumably due to DOM churn.  Interestingly, deleting/detaching ALL the images does work - as soon as the command executes, the memory is released. However this causes its own problems, managing the UI state, and building the carousel back up also takes a noticeable amount of time.  Refreshing the page is another workaround, but that causes even more UX disruption.</p>
  
  <p><strong>Update 04/10:</strong>
  Just an update on what we ended up doing:  iOS 4.2 introduced a limitation that cuts off a  3D transformed Div at 122,900 pixels.  Not sure why, but it forced us to re-architect and go with a dynamic carousel instead of our previous static filmstrip.</p>
  
  <p>Second, we found that using divs with background images work better than images themselves.  This seems like a yet another bug in Safari, or at best an inconsistent limitation implementation.</p>
  
  <p><strong>end update</strong></p>
  
  <p><s>Thoughts?</s> If you have encountered suspected leaks in Safari, what has been your approach to work around them?</p>