font data not being freed

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

gjaegy
Just popping in
Just popping in
Posts: 14
Joined: Thu Mar 04, 2010 12:18

font data not being freed

Postby gjaegy » Fri Sep 14, 2012 17:33

Hi,

I am trying to catch a memory leak, basically, my FreeTypeFont::d_fontData is not destroyed, and I don't know why (all the other resources allocated by CEGUI are being freed up).

I am using the latest version from the source repository.

I am instancing my GUI from Lua (see whole script below).

The d_fontData is being allocated in FreeTypeFont:updateFon():

Code: Select all

    System::getSingleton().getResourceProvider()->loadRawDataContainer(
        d_filename, d_fontData, d_resourceGroup.empty() ?
            getDefaultResourceGroup() : d_resourceGroup);


Shall I manually delete it ? That doesn't sound right, as I am not instancing it by myself... What am I doing wrong (or actually not doing) ?

Thanks,

Below the script I am using:

Code: Select all

local oScriptInterface = imScriptInterface.g_TheScriptInterface;
local oScene = oScriptInterface:GetActiveScene();

local oSimManager = imSimManager.g_TheSimManager;   
local oDrivingSim = oSimManager:GetDrivingSimulator();

local bFirstUpdate = 1;

-------------------------------------------------------------------------------------------------

function updateHandler(args)
    local root = CEGUI.System:getSingleton():getDefaultGUIContext():getRootWindow()

   local sBrakeForceText = oDrivingSim:ScriptGetBrakeForcePerSecSqPerKg();
   root:getChild("root/ADTTuningWindow/EditboxBrakeForceCurrent"):setText(sBrakeForceText)

   local sFrictionText = oDrivingSim:ScriptGetFrictionRatio();
   root:getChild("root/ADTTuningWindow/EditboxFrictionCurrent"):setText(sFrictionText)
   
   if (bFirstUpdate == 1) then
      root:getChild("root/ADTTuningWindow/EditboxBrakeForceNew"):setText(sBrakeForceText)
      root:getChild("root/ADTTuningWindow/EditboxFrictionNew"):setText(sFrictionText)
      bFirstUpdate = 0
   end
end

-------------------------------------------------------------------------------------------------

-----------------------------------------
-- Script Entry Point
-----------------------------------------
local guiSystem = CEGUI.System:getSingleton()
local schemeMgr = CEGUI.SchemeManager:getSingleton()
local winMgr = CEGUI.WindowManager:getSingleton()

-- load our scheme
local scheme = schemeMgr:createFromFile("AlfiskoSkin.scheme");
-- load our window layout
local window = winMgr:loadLayoutFromFile("ADTTuning.layout")
-- set the layout as the root
local root = CEGUI.System:getSingleton():getDefaultGUIContext():getRootWindow()
root:addChild(window);

-- set default mouse cursor
guiSystem:getDefaultGUIContext():getMouseCursor():setDefaultImage("AlfiskoSkin/MouseArrow")

-- subscribe required events
root:getChild("root/ADTTuningWindow"):subscribeEvent("Updated", "updateHandler")

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: font data not being freed

Postby Kulik » Sat Sep 15, 2012 09:19

I see it being freed in updateFont. It could be some bug specific to your scenario, please do some more digging :-)

gjaegy
Just popping in
Just popping in
Posts: 14
Joined: Thu Mar 04, 2010 12:18

Re: font data not being freed

Postby gjaegy » Thu Sep 20, 2012 08:58

It is being freed *before* it's being loaded, to make sure all objects allocated before the loading are being destroyed:

Code: Select all

void FreeTypeFont::updateFont()
{
    free();

    System::getSingleton().getResourceProvider()->loadRawDataContainer(
        d_filename, d_fontData, d_resourceGroup.empty() ?
            getDefaultResourceGroup() : d_resourceGroup);


However, it's not being freed afterthat...

I have managed to solve the issue by calling the following clean up code at application exit:

Code: Select all

FontManager::getSingleton().destroyAll();


Problem solved :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests