Calling crypto.webkitSubtle.generateKey causes page memory to never be released

Originator:sfrost007
Number:rdar://18940687 Date Originated:11/11/2014
Status:Closed Resolved:4/8/2015
Product:Safari Product Version:7.1, 8.0, (others?)
Classification:Performance Reproducible:Always
 
Summary:
If a call is made to crypto.webkitSubtle.generateKey, any memory allocated in the page's lifetime will not be released on unload. This can be most easily demonstrated by allocating a large ArrayBuffer and repeatedly refreshing the page.

If the same ArrayBuffer is allocated but generateKey is *not* called, the memory is correctly released when the page is refreshed.

Steps to Reproduce:
1. Open Activity Monitor
2. Switch to Memory tab
3. Search for "Safari" to reduce list
4. Start a new Safari session and open sample page (code below)
5. Refresh page repeatedly. Memory usage will grow by ~128mb (as allocated by sample test page) per refresh.

Expected Results:
Memory allocated by page is not leaked on page refresh. This is the case if the call to generateKey is skipped.

Actual Results:
Memory usage grows unbounded.

Version:
Safari 7.1 (9537.85.10.17.1), OS X 10.9.5, Mid 2010 iMac with 12GB RAM
Safari 8.0 (10600.1.25), OS X 10.10.1, Late 2010 MacBook Air with 4GB RAM

Notes:
Above configurations are the only ones tested; No configurations have been tested and not exhibited this issue.

Configuration:
Safari 7.1 (9537.85.10.17.1), OS X 10.9.5, Mid 2010 iMac with 12GB RAM
Safari 8.0 (10600.1.25), OS X 10.10.1, Late 2010 MacBook Air with 4GB RAM


Sample code:
	var leak = new ArrayBuffer(128*1024*1024);
	var rsa = {
		modulusLength: 1024,
		publicExponent: new Uint8Array(1,0,1,0),
		name: "RSA-OAEP",
		hash: { name: "SHA-256" }
	};
	window.crypto.webkitSubtle.generateKey(rsa, true, ['encrypt', 'decrypt']);

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!