【Ubuntu】メモリリーク解消のためのフォントttf-mscorefonts-installerのインストール

  • agxViewerまたはagxOSG::ExampleApplicationを使うアプリケーションはUbuntuに標準でインストールされていないフォントを求めることがある。

  • フォントが存在しないとエラー Error reading file arial.ttf: file not found が出力され、メモリーリークを引き起こすことがある。

  • メモリーリークはAGXが利用しているグラフィックスライブラリOpenSceneGraph 3.6.4の問題 [1] である。

  • Microsoftフォント「ttf-mscorefonts-installer」をインストールすることで、問題が起きないようにする。

  • 確認環境

    • OS: Ubuntu 22.04 LTS

    • AGXバージョン: agx-2.38.0.1-amd64-ubuntu_22.04.deb

インストール手順

ターミナルを開き、次のコマンドを実行する。

# Microsoftのフォントをインストール.要EULAの同意
sudo apt install ttf-mscorefonts-installer
ls -al /usr/share/fonts/truetype/msttcorefonts | grep arial    # arial.ttfが見つかること

# AGXからフォントを参照できるように環境変数を追加
cd ~
cp -p .bashrc .bashrc.`date "+%Y%m%d_%H%M%S"`       # .bashrcのバックアップ
echo 'export OSG_FILE_PATH=/usr/share/fonts/truetype/msttcorefonts:$OSG_FILE_PATH' >> .bashrc   # フォントへのパスを追加
diff .bashrc .bashrc.xxxxxx                         # 変更差分確認