Summary: | Memory leaks due to FcStrStaticName use for external patterns | ||
---|---|---|---|
Product: | fontconfig | Reporter: | Karl Tomlinson <bugs.freedesktop> |
Component: | library | Assignee: | Karl Tomlinson <bugs.freedesktop> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | medium | CC: | akira, caolanm, fontconfig-bugs, freedesktop, michael.meeks |
Version: | 2_1 | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: |
Replace static strings with reference counted strings
Increase the number of buckets in the shared string hash table |
Description
Karl Tomlinson
2008-09-29 20:27:22 UTC
(In reply to comment #0) > Strings are never uninterned. Well, they are uninterned at FcFini, but I assume the application would only be expected to call FcFini on exit. Have any suggested patch? To enlarge the hash table at least or something? Otherwise I'd like to close this until it actually becomes a problem. May be worth a comment in the source file. (In reply to comment #0) > Also, FcStrHashed() should compare pointers rather than contents of strings > when deciding whether they should be freed. This was fixed in bug 17661, thanks. Created attachment 33707 [details] [review] Replace static strings with reference counted strings With this, the number of strings in the hash table is limited to the number that are currently in use. Created attachment 33708 [details] [review] Increase the number of buckets in the shared string hash table This is a reasonably conservative increase in the number of buckets in the hash table to 251. After FcInit(), there are 240 shared strings in use on my system (from configuration files I assume). The hash value is stored in each link in the chains so comparison are actually not very expensive. This change should reduce the average length of chains by a factor of 8. With the reference counted strings, it should keep the average length of chains to about 2. The number of buckets is prime so as not to rely too much on the quality of the hash function. With the patch in comment #4 applied I get (given the random amount of fonts I've got installed) a 145k reduction in LibreOffice memory footprint (idling with a single blank writer document opened) Both patches look good. If Firefox and OO.o run happily on it, it should be good ;). Merged patches in master branch. thanks! |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.