Note: There are a few cases of duplicates in user autocompletion which are being worked on.

Hidden memory costs of strings in nsCacheEntry instances

RESOLVED FIXED

Status

()

Core
Networking: Cache
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: azakai, Assigned: azakai)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(fennec2.0next+)

Details

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
nsCacheEntry reports its Size as mDataSize + mMetaData.Size(). However, it also holds a pointer to an nsCString (mKey) which it keeps alive. When testing on popular websites like google.com, you often see mKey be 300-400 bytes in length. As a result, in many cases the size of mKey is of the order of what nsCacheEntry reports as its size.

In other words, there is a potentially significant amount of memory that is used but not reported to about:cache, and not taken into consideration for how many entries to keep in the cache (but this isn't technically a leak). In a simple benchmark (see 'test page' attachment in bug 634642, run over hundreds of page loads), it looks like mKey is an additional 20% over the reported size of nsCacheEntry.
(Assignee)

Comment 1

6 years ago
Created attachment 519252 [details] [diff] [review]
patch

Patch makes nsCacheEntry::Size() take into account the length of mKey, so it more accurately represents how much memory the nsCacheEntry uses.
(Assignee)

Updated

6 years ago
Assignee: nobody → azakai
(Assignee)

Comment 2

6 years ago
Comment on attachment 519252 [details] [diff] [review]
patch

Looks good on try.

biesi, can you please take a look (or tell me who I should ask, I'm not sure who reviews netwerk/cache stuff)?
Attachment #519252 - Flags: review?(cbiesinger)
(Assignee)

Comment 3

6 years ago
Requesting blocking-fennec since this can save 1MB of memory in some cases (we allow 1MB for memory cache, and the amount of memory actually used can be twice as much due to these strings).
tracking-fennec: --- → ?

Comment 4

6 years ago
Lets get this in to our next release
tracking-fennec: ? → 2.0-
tracking-fennec: 2.0- → 2.0next+
Comment on attachment 519252 [details] [diff] [review]
patch

Yeah, cache patches get reviewed by me or one of the other necko peers
Attachment #519252 - Flags: review?(cbiesinger) → review+
(Assignee)

Comment 6

6 years ago
http://hg.mozilla.org/mozilla-central/rev/8dbfdd56997b
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.