View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0033668 | Open CASCADE | OCCT:Coding | public | 2024-04-05 17:15 | 2024-04-05 17:22 |
Reporter | vtryputs | Assigned To | dpasukhi | ||
Priority | normal | Severity | minor | ||
Status | new | Resolution | open | ||
Platform | Wasm | ||||
Product Version | 7.8.0 | ||||
Summary | 0033668: Coding - Memory leak during call Font_FTFont::FindAndCreate | ||||
Description | Memory leak in wasm during call Font_FTFont::FindAndCreate after register the font using Font_FontMgr::GetInstance()->Register Find some strange behavior with provided code: on wasm side it crashes the application because of out of memory (didn't reproduced the issue on native (ubuntu 22.04 application)), it only happens after register custom font using 'Font_FontMgr::GetInstance()->Register' on wasm. OCCT commit: f60082f9fb70440a6e77c3e37918de166bacc264 Freetype commit: e4586d960f339cf75e2e0b34aee30a0ed8353c0d | ||||
Steps To Reproduce | 1. Load new font using:void OccViewer::_cppRegisterFont (const std::string& theFontFile, const std::string& theFontName, bool theToOverride) { if (Handle (Font_SystemFont) aFont = Font_FontMgr::GetInstance()->CheckFont (theFontFile.c_str())) { if (!theFontName.empty()) { Handle (Font_SystemFont) aFont2 = aFont; aFont = new Font_SystemFont (theFontName.c_str()); for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter) { aFont->SetFontPath ((Font_FontAspect)anAspectIter, aFont2->FontPath ((Font_FontAspect)anAspectIter), aFont2->FontFaceId ((Font_FontAspect)anAspectIter)); } } Font_FontMgr::GetInstance()->RegisterFont (aFont, theToOverride); //const Handle (OccViewer)& anInstance = Instance(); //const Handle (Prs3d_Drawer)& aDefaultDrawer = anInstance->Context()->DefaultDrawer(); //Handle (Prs3d_TextAspect) aTextAspect = aDefaultDrawer->TextAspect(); //aTextAspect->Aspect()->SetFont (aFont->FontName()); } else { Message::DefaultMessenger()->SendFail() << "Error: font '" << theFontFile << "' is not found"; } } 2. Run provided code to reach out of memory auto findAndCreate = []() { Font_FTFontParams aFontParams; aFontParams.PointSize = 10; aFontParams.Resolution = 96; aFontParams.FontHinting = Font_Hinting_Off; Handle (Font_FTFont) aFont = Font_FTFont::FindAndCreate ("serif", Font_FontAspect_Regular, aFontParams); }; for (int i = 0; i < 100; i++) { findAndCreate(); } | ||||
Tags | No tags attached. | ||||
Test case number | |||||
Date Modified | Username | Field | Change |
---|---|---|---|
2024-04-05 17:15 | vtryputs | New Issue | |
2024-04-05 17:15 | vtryputs | Assigned To | => dpasukhi |
2024-04-05 17:15 | vtryputs | File Added: image.png | |
2024-04-05 17:22 | dpasukhi | Platform | => Wasm |
2024-04-05 17:22 | dpasukhi | Summary | Memory leak in wasm during call Font_FTFont::FindAndCreate after register the font using Font_FontMgr::GetInstance()->Register => Coding - Memory leak during call Font_FTFont::FindAndCreate |
2024-04-05 17:22 | dpasukhi | Description Updated | |
2024-04-05 17:22 | dpasukhi | Steps to Reproduce Updated |