Reduce memory usage of FreeCAD and OrcaSlicer

FreeCAD

On my Debian 13 x86-64 this runs well. Main idea: Qt PySide compiles and embed QRC into huge xxx_rc.py, I dump data as bin file and use open().

curl -o FreeCAD.AppImage -L https://github.com/FreeCAD/FreeCAD/releases/download/weekly-2025.10.31/FreeCAD_weekly-2025.10.31-Linux-x86_64-py311.AppImage
chmod +x FreeCAD.AppImage
./FreeCAD.AppImage --appimage-extract
pushd squashfs-root/usr ; rm -rf man fonts ssl ; popd
pushd squashfs-root/usr/share ; rm -rf doc icons man mysql opencv4 ; popd
pushd squashfs-root/usr/lib ; rm -rf qt6/bin qt6/plugins/qmlls qt6/qml/QtQuick $(ls | grep -E "^(lib)?(LLVM|clang|openvino|avcodec|rav1e|dav1d|avif|x265|x264|aom|SvtAv1Enc|opencv|mysqlclient|(open)?blas(p)?|pcl|protoc|protobuf|gtk)[\._-]") ; popd # vtk is used by mesh files like stl
pushd squashfs-root/usr/lib/python3.11/site-packages ; rm -rf OCC pandas scipy ifcopenshell matplotlib pip ; popd # vtkmodules
pushd squashfs-root
for entry in $(find -name "*_rc.py"); do
  suffix="$(tail -n 8 $entry | tr "\n" "|")"
  (tail -n +8 $entry | head -n -8 ; printf "with open(__file__+'.qrc_name.bin','wb')as f:\n    f.write(qt_resource_name)\nwith open(__file__+'.qrc_struct.bin','wb')as f:\n    f.write(qt_resource_struct)\nwith open(__file__+'.qrc_data.bin','wb')as f:\n    f.write(qt_resource_data)\nexit()") > $entry.tmp
  mv $entry.tmp $entry
  python3 $entry
  (printf "from PySide6 import QtCore\nwith open(__file__+'.qrc_name.bin','rb')as f:\n    qt_resource_name=f.read()\nwith open(__file__+'.qrc_struct.bin','rb')as f:\n    qt_resource_struct=f.read()\nwith open(__file__+'.qrc_data.bin','rb')as f:\n    qt_resource_data=f.read()\n" ; echo "$suffix" | tr "|" "\n") > $entry
done
popd
mv squashfs-root FreeCAD
# wayland: https://github.com/FreeCAD/FreeCAD/issues/6068
# see mkdebian, todo: a new post for 2 block xz
# tar -c FreeCAD | xz -T2 -9e --block-size $(( $(tar -c FreeCAD | wc -c) / 2 + 64 )) > FreeCAD.tar.xz

Before (left) and after (right):

Screenshot to compare memory usage

OrcaSlicer

curl -o OrcaSlicer.AppImage -L https://github.com/SoftFever/OrcaSlicer/releases/download/v2.3.1/OrcaSlicer_Linux_AppImage_Ubuntu2404_V2.3.1.AppImage
chmod +x OrcaSlicer.AppImage
./OrcaSlicer.AppImage --appimage-extract
apt install --no-install-recommends libwebkit2gtk-4.1-0 # for debian 13
# reduce memory usage a lot
mv resources/fonts resources/fonts.bak
mv resources/web/homepage/index.html resources/web/homepage/index.html.bak
echo '<!doctype html><html style="background:#000"><script>window.close()</script>' > resources/web/homepage/index.html
# force enable dark mode
export GTK_THEME=adw-gtk3-dark
export ORCA_SLICER_DARK_THEME=true
# kill webkit processes
(nohup sh -c 'sleep 3 ; kill $(pgrep -P $(pgrep orcaslicer_main))' > /dev/null 2>&1 &)