Changes between Initial Version and Version 1 of Memory Use


Ignore:
Timestamp:
Jul 9, 2008 8:30:19 PM (16 years ago)
Author:
ggaren@apple.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Memory Use

    v1 v1  
     1== Required information in an Excessive Memory Use Bug ==
     2
     3'''1. Memory use numbers'''
     4
     5Please provide numbers for the memory use you observe.
     6
     7On Mac: Run "Activity Monitor", and record the "RPRVT" number. (You may have to enable this column manually by right-clicking on the column headers and selecting "Private Memory".)
     8
     9On Windows: Run "Task Manager", and record the "Private Working Set" number. (You may have to enable this column manually. See http://cybernetnews.com/2007/11/20/cybernotes-windows-memory-usage-explained/.)
     10
     11'''2. "Steps to reproduce", including OS version'''
     12
     13Please provide an exact set of steps that an engineer can follow in order to reproduce the numbers you report, starting with, "Launch Safari."
     14
     15The steps should show that memory use goes up without coming back down.
     16
     17The steps should employ a fixed set of web content. (It's normal for memory use to go up as you load more and more content -- that's a result of caching.)
     18
     19If possible, include a reduced test case that includes just the portions of web content necessary to reproduce the behavior you report, and not any surrounding or related content. This will make debugging the issue much easier.
     20
     21==  Examples of good Excessive Memory Use Bugs ==
     22
     23Below are some examples of good memory use bugs.
     24
     25** "Memory use goes up by 500KB every time I reload gmail.com" **
     26
     27OS: Windows XP SP2.
     28
     29Steps to reproduce:
     301. Launch Safari
     312. Load gmail.com. Memory use: 15MB
     323. Click the "reload" button. Memory use: 15.5MB
     334. Click the "reload" button. Memory use: 16.0MB
     34
     35After 10 reloads, memory reaches 20.0MB.
     36
     37** "Safari uses 20MB more memory than IE7 when loading a specific set of websites in tabs" **
     38
     39OS: Mac OS X 10.5.2.
     40
     41Steps to reproduce:
     421. Launch Safari and IE7.
     43
     44Safari's memory use: 16MB.
     45IE7's memory use: 16MB.
     46
     472. Load the following URLs in tabs: cnn.com, apple.com, nytimes.com, slashdot.org, digg.com
     48
     49Safari memory use: 38MB
     50IE7's memory use: 18MB.
     51
     52** "Memory use grows by 165KB every time I load a 165KB file by XMLHttpRequest" **
     53
     54OS: Mac OS X 10.4.3.
     55
     56Steps to reproduce:
     571. Launch Safari.
     582. Load the attached reduced test case. Memory use: 17MB.
     593. Click the "make an XMLHttpRequest" button. Memory use: 17.165MB.
     604. Click the "make an XMLHttpRequest" button. Memory use: 17.330MB.
     61
     62After 10 clicks, memory use reaches 18.65MB.
     63
     64==  Tools for Diagnosing an Excessive Memory Use Bug ==
     65
     66Use a debug build of WebKit. It will give you more diagnostic information.
     67
     68On Windows: Launch Safari from the cygwin terminal, with standard output enabled: run-safari --debug 2>&1 | cat
     69
     70On Mac: Launch Safari from the terminal: WebKitTools/Scripts/run-safari --debug
     71
     72Having reproduced the bug, follow these steps in order, to diagnose common causes of memory use:
     73
     74'''1. Close all windows'''
     75
     76On Windows: Open a dummy empty window. Close all other windows. (Closing all windows would quit Safari.)
     77
     78On Mac: Close all windows.
     79
     80Record whether the memory use number returned to normal.
     81
     82On Mac: Record whether you saw a "World Leak" dialog.
     83
     84On Windows: Using the debugger, record 'PageLoadTestRunner::worldLeaksString()'. You should see only 1 WebView and 1 WebFrame (your empty window).
     85
     86'''2. Check the JavaScript object footprint'''
     87
     88Select Debug -> Show Caches Window.
     89
     90Click the "Garbage Collect JavaScript Objects" button.
     91
     92Record whether the memory use number returned to normal.
     93
     94Record whether the "Total Objects", "Global Objects", and "Protected Objects" counts in the "JavaScript Objects" box returned to 0.
     95
     96'''3. Check the cache footprint'''
     97
     98Select Debug -> Show Caches Window.
     99
     100Click the "Empty WebCore Cache" button. Record whether the memory use number returned to normal.
     101
     102Click the "Empty NSURLCache" button. Record whether the memory use number returned to normal.
     103
     104Click the "Purge Inactive Font Data" button. Record whether the memory use number returned to normal.
     105
     106'''4. Check for leaks - I'''
     107
     108Quit the application. Record any "LEAK: " messages you see in the terminal.
     109
     110* This step will yield false positives until we fix the fast teardown / GC bug.
     111
     112'''5. Check for leaks - II (Mac only)'''
     113
     114Relaunch Safari with malloc logging enabled: MallocStackLogging=1 ./Safari.app/Contents/MacOS/Safari.
     115
     116After reproducing the bug, run the "leaks" command-line tool, and record the "Process X: Y leaks for Z total leaked bytes" line, along with backtraces from substantial leaks.
     117
     118'''6. Try the hard stuff'''
     119
     120The steps above cover common causes of memory use. If none of them reveals the culprit, you'll need to dig deeper.
     121
     122On Windows: Use umdh.exe to track down who's using memory and why.
     123
     124On Mac: Use malloc_history to track down who's using memory and why.
     125
     126You can google for more information about these tools. We hope to have detailed instructions for using them, along with helper tools, soon.