freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] FT_Outline memory overallocation, or at least incorrect cache


From: Paul Messmer
Subject: [ft-devel] FT_Outline memory overallocation, or at least incorrect cache weighting?
Date: Thu, 4 Feb 2010 15:29:28 -0800

Hi all.  I have a situation where the FreeType glyph cache is consuming more RAM than I expect it to.  After some investigation I discovered the following:

.../cache/ftcimage.h: ftc_inode_weight()

        outg = (FT_OutlineGlyph)glyph;
        size = outg->outline.n_points *
                 ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
               outg->outline.n_contours * sizeof ( FT_Short ) +
               sizeof ( *outg );

The code above seems to believe there are n_points FT_Vectors allocated.  However,

.../base/ftoutln.c:  FT_Outline_New_Internal()

    if ( FT_NEW_ARRAY( anoutline->points,   numPoints * 2L ) ||
         FT_NEW_ARRAY( anoutline->tags,     numPoints      ) ||
         FT_NEW_ARRAY( anoutline->contours, numContours    ) )
      goto Fail;
    anoutline->n_points    = (FT_UShort)numPoints;

This seems to be allocating 2*n_points FT_Vectors, so there's a difference between how much memory is actually being used and how much it believes is being used.  Worse though, it looks to me like it's a case of overallocation instead of simply under-reporting, and ~half the outline's memory is unused?  I'm not 100% sure about the latter as I see in some places outline->points[x] is being addressed with x >= outline->n_points, but perhaps this is just special-case four-"phantom"-point code in the TrueType loader.

Thanks,
-- Paul

reply via email to

[Prev in Thread] Current Thread [Next in Thread]