WebKit Bugzilla
Attachment 359291 Details for
Bug 193504
: Memory leak with IDB openCursor()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
leak demonstration
Leak Demo with openCursor().html (text/html), 1.79 KB, created by
zac spitzer
on 2019-01-16 12:21:49 PST
(
hide
)
Description:
leak demonstration
Filename:
MIME Type:
Creator:
zac spitzer
Created:
2019-01-16 12:21:49 PST
Size:
1.79 KB
patch
obsolete
> ><!DOCTYPE html> ><title>Leak Demo with openCursor()</title> >open the web inspector and reload, then checkout the timelines tab, there's an 85 MB leak ><script> >var DBNAME = 'cursor_leak'; >var VERSION = '1'; >var STORE = "dummy"; >var db; >var str = "i am a test string"; > >self.onload = function () { > indexedDB.deleteDatabase(DBNAME); > var request = indexedDB.open(DBNAME, VERSION); > > request.onupgradeneeded = function(event) { > db = event.target.result; > // Create a new object store if this is the first time we're using > // this DB_NAME/DB_VERSION combo. > db.createObjectStore(STORE, {autoIncrement: true}); > }; > request.onerror = function(err){ > console.error(err); > }; > > request.onsuccess = function (event) { > db = request.result; > prepTest(db); > }; >}; >function prepTest(db){ > var trans = db.transaction(STORE, "readwrite"); > var store = trans.objectStore(STORE); > // lets insert a large object > store.put({ > a: str.repeat(5000000), > b: str.repeat(5000000) > }); > > trans.oncomplete = function(){ > runtest(db); > }; >} > >function cb(result){ > if (console.takeHeapSnapshot) > console.takeHeapSnapshot("result"); > console.log(result); >} > >function runtest(db) { > var objectStore = db.transaction(STORE).objectStore(STORE); > var toReturn = []; > objectStore.openCursor().onsuccess = function(event) { > //var cursor = event.target.result; > if (event.target.result) { > toReturn.push(event.target.result.value); > event.target.result['continue'](); > } else { > if (cb) > cb(toReturn); > } > }; > > if (self.gc) { > self.gc(); > console.info("gc"); > } > done(); >} > >function done() { > setTimeout( > function() { > if (self.gc) { > console.error("forcing GC"); > self.gc(); > } > }, > 2000 > ); >} > ></script>
<!DOCTYPE html> <title>Leak Demo with openCursor()</title> open the web inspector and reload, then checkout the timelines tab, there's an 85 MB leak <script> var DBNAME = 'cursor_leak'; var VERSION = '1'; var STORE = "dummy"; var db; var str = "i am a test string"; self.onload = function () { indexedDB.deleteDatabase(DBNAME); var request = indexedDB.open(DBNAME, VERSION); request.onupgradeneeded = function(event) { db = event.target.result; // Create a new object store if this is the first time we're using // this DB_NAME/DB_VERSION combo. db.createObjectStore(STORE, {autoIncrement: true}); }; request.onerror = function(err){ console.error(err); }; request.onsuccess = function (event) { db = request.result; prepTest(db); }; }; function prepTest(db){ var trans = db.transaction(STORE, "readwrite"); var store = trans.objectStore(STORE); // lets insert a large object store.put({ a: str.repeat(5000000), b: str.repeat(5000000) }); trans.oncomplete = function(){ runtest(db); }; } function cb(result){ if (console.takeHeapSnapshot) console.takeHeapSnapshot("result"); console.log(result); } function runtest(db) { var objectStore = db.transaction(STORE).objectStore(STORE); var toReturn = []; objectStore.openCursor().onsuccess = function(event) { //var cursor = event.target.result; if (event.target.result) { toReturn.push(event.target.result.value); event.target.result['continue'](); } else { if (cb) cb(toReturn); } }; if (self.gc) { self.gc(); console.info("gc"); } done(); } function done() { setTimeout( function() { if (self.gc) { console.error("forcing GC"); self.gc(); } }, 2000 ); } </script>
View Attachment As Raw
Actions:
View
Attachments on
bug 193504
: 359291