5

I'm using an IndexedDB for saving game data in Chrome.

An average game is about 4MB. After saving a few games, and then deleting them, the dev console's 'Resources' tab shows that my indexedDB is empty, as expected, but if I go to content settings, "Cookies and site data" it's showing me roughly 12MB as the indexedDB size on disk.

This is a after a refresh and even a restart of Chrome. The following is my code for deletion and I'm getting success when I delete and a query for the old data returns nothing, as expected.

database.indexedDB.deleteGame = function(nameIn){
    var db = database.indexedDB.db;
    var trans = db.transaction(["saves"], "readwrite");
    var store = trans.objectStore("saves");
    var wipeSlate = store.delete(nameIn);
    wipeSlate.onsuccess = function(e) {
        console.log("Old game wiped");
    };
    wipeSlate.onerror = function(e) {
        console.log("I don't think the old game existed..." + e);
    };
};

I've checked the following questions (and search results aren't showing anything too promising either):

But none of them deal with my question, any and all help very much appreciated.

Community
  • 1
  • 1
agryson
  • 297
  • 2
  • 9

2 Answers2

5

Chrome doesn't immediately delete the data from disk, it is just marked deleted. If you write ~4 more megabytes to IndexedDB, LevelDB will do a compaction and the files containing the old entries will be deleted.

Chrome has no 50mb limit and will not ever ask for user permission for IndexedDB.

This question may be helpful. What are the storage limits for the Indexed DB on Google's Chrome browser?

Community
  • 1
  • 1
dgrogan
  • 2,587
  • 1
  • 17
  • 21
0

Why are you worrying?

OS and Browser may take holistic approach to optimize user experience. Storage is one of them. In most situation, rather than deleting, marked them as deleted are more efficient.

Kyaw Tun
  • 12,447
  • 10
  • 56
  • 83
  • 1
    As IndexedDB has a limit of 50MB before asking for user permission, I was hoping to put off asking the user for permission as much as possible. I presume, given what you've said, that upon getting close to 50MB I can let chrome worry about liberating the space? – agryson Apr 07 '13 at 12:07
  • Yes, let browser to take care of the mess. – Kyaw Tun Apr 07 '13 at 13:08
  • Thank you, though for your answer, could you link me to some confirmation that that is actually the case? I'd like to confirm that what I'm seeing is not a bug. – agryson Apr 07 '13 at 14:00
  • Find your claim in IndexedDB API spec http://www.w3.org/TR/IndexedDB/ then file a bug for any deviation. – Kyaw Tun Apr 07 '13 at 14:07
  • Thanks for the link, regarding @dgrogan's answer, I think it's not necessarily a bug but expected behaviour, that as you say in your answer is nothing to worry about. – agryson Apr 08 '13 at 15:27
  • 2
    There is reason to worry - although the deleted files don't show they appear to still count towards the storage quota for the domain. I have been testing on Samsung S5 with Chrome55 and if I added enough to exceed the quota I was still getting a quota exceeded error even after clearing the store of all data, closing all tabs and restarting Chrome. The only way to reset the quota was to clear cache in settings. – Joe Coulson Jan 11 '17 at 12:15