Closed
Bug 115752
Opened 24 years ago
Closed 24 years ago
gif_write : memory churn
Categories
(Core :: Graphics: ImageLib, defect, P3)
Tracking
()
RESOLVED
FIXED
mozilla0.9.8
People
(Reporter: dp, Assigned: dp)
Details
(Keywords: perf)
Attachments
(1 file, 1 obsolete file)
|
10.54 KB,
patch
|
pavlov
:
review+
|
Details | Diff | Splinter Review |
gif_write() allocates memory for prefix, suffix and stack for lzw decompression
for every image. These buffers are fixed size 4097, 4097, 8194 bytes.
We could recycle these buffers easily. We read about 120 image files on startup.
| Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla0.9.8
| Assignee | ||
Comment 1•24 years ago
|
||
On startup this would reduce:
360 [120 * 3] allocations/free
2,063,760 [120 * 8k + 240 * 4k] of memory chrun
| Assignee | ||
Comment 2•24 years ago
|
||
Ccing simon for sr=
Comment 3•24 years ago
|
||
+#define NBUCKETS 3
Prefer const PRInt32 kNumBuckets = 3;
It's also the case that you can't have more than 32 buckets (limited by the
mFlags), so you should comment this.
+ // Clear the buckets of memory we have for zlib
+ int ClearBuckets();
int? Also, what does the return value mean? You always return 0.
+
+#define IS_IN_USE(i) (mFlag & (1 << i))
+#define MARK_USED(i) mFlag |= (1 << i)
+#define CLEAR_USED(i) mFlag &= ~(1 << i)
Prefer inline functions (you are such the old unix hacker!). Then you can assert
if i > 31.
+ nsGifAllocator() : mFlag(0)
You shoudl initialize mLock to nsnull too.
+ for (int i = 0; i < NBUCKETS; i++)
PRInt32?
+ mMemBucket[i] = 0;
minor niggle; I prefer using nsnull for null pointers, to disambiguate with
coding mistakes where you thought mMemBucket[] was a value, rather than a
pointer.
+ int freeAllocatedBucket = -1;
PRInt32?
+static inline void
+gif_free(void *ptr)
+{
...
+ if (!gGifAllocator)
+ gGifAllocator = new nsGifAllocator;
...
Is it ever worth making the allocator in a gif_free? If you can't guarantee
you've called gif_calloc before, you might as well just free().
Finally, do we want to hook up this cache to the memory flusher? It could hold up
to 128K of memory.
| Assignee | ||
Comment 4•24 years ago
|
||
This keeps only 16k (not 128k). For now it gets freed at module shutdown. Later
we will think about rolling a timer and cleaning it up.
Attachment #62109 -
Attachment is obsolete: true
Comment 5•24 years ago
|
||
Comment on attachment 62150 [details] [diff] [review]
Includes comments from Simon
r=pavlov
Attachment #62150 -
Flags: review+
Comment 6•24 years ago
|
||
Kill those 'returns' in the inline methods, and sr=sfraser
| Assignee | ||
Comment 7•24 years ago
|
||
Removed the returns. Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 8•24 years ago
|
||
Hey dp, you left a naked printf in the checkin, and it's spewing dozens of
messages into the console while running the page-loader test
(libpr0n/decoders/gif/GIF2.cpp
DEBUG: global_colormap - 16 [4 x 4]
DEBUG: global_colormap - 1024 [256 x 4]
DEBUG: global_colormap - 1024 [256 x 4]
DEBUG: global_colormap - 1024 [256 x 4]
DEBUG: global_colormap - 512 [128 x 4]
If someone kills that printf then mark this fixed again.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 9•24 years ago
|
||
seawood checked in a fix for this, BTW
| Assignee | ||
Comment 10•24 years ago
|
||
Thanks seawood.
Status: REOPENED → RESOLVED
Closed: 24 years ago → 24 years ago
Resolution: --- → FIXED
Comment 11•23 years ago
|
||
The Image Conversion Library component is going away.
Component: Image Conversion Library → ImageLib
You need to log in
before you can comment on or make changes to this bug.
Description
•