I tried stripping only the physics out to see the implications on memory and package size. May as well dump my findings here.
Because I didn’t want to spend too much time I only tested on macOS builds, the memory could differ from device to device though so keep that in mind. I built each version for macOS and got the memory with profiler.get_memory_usage(). I restarted the whole game after each sample and I used 9 samples. Testes done with engine version 1.2.117 and in release mode.
TLDR; The package size decrease is nice but memory implication is pretty meh.
appmanifest
# Release + No: Physics
platforms:
x86_64-osx:
context:
excludeLibs: ["BulletDynamics", "BulletCollision", "LinearMath", "Box2D", "physics"]
libs: ["engine_release", "physics_null"]
x86_64-linux:
context:
excludeLibs: ["BulletDynamics", "BulletCollision", "LinearMath", "Box2D", "physics"]
libs: ["engine_release", "physics_null"]
js-web:
context:
excludeLibs: ["BulletDynamics", "BulletCollision", "LinearMath", "Box2D", "physics"]
libs: ["engine_release", "physics_null"]
x86-win32:
context:
excludeLibs: ["libBulletDynamics", "libBulletCollision", "libLinearMath", "libBox2D", "libphysics"]
libs: ["libengine_release.lib", "libphysics_null.lib"]
x86_64-win32:
context:
excludeLibs: ["libBulletDynamics", "libBulletCollision", "libLinearMath", "libBox2D", "libphysics"]
libs: ["libengine_release.lib", "libphysics_null.lib"]
armv7-android:
context:
excludeLibs: ["BulletDynamics", "BulletCollision", "LinearMath", "Box2D", "physics"]
libs: ["engine_release", "physics_null"]
armv7-ios:
context:
excludeLibs: ["BulletDynamics", "BulletCollision", "LinearMath", "Box2D", "physics"]
libs: ["engine_release", "physics_null"]
arm64-ios:
context:
excludeLibs: ["BulletDynamics", "BulletCollision", "LinearMath", "Box2D", "physics"]
libs: ["engine_release", "physics_null"]
Memory
Data of an empty project, with physics
|
Empty |
5 Collections from file |
5 Collection Proxies |
5 Collection Proxies - Loaded |
Average MB |
38.9 |
38.8 |
38.7 |
40.5 |
Average Bytes |
38884693 |
38763633 |
38673066 |
40482588 |
The data collected indicates that each collection proxy adds 0.36 MB of memory.
Data of an empty project, without physics
|
Empty |
5 Collections from file |
5 Collection Proxies |
5 Collection Proxies - Loaded |
Average MB |
38.6 |
38.4 |
38.6 |
40.2 |
Average Bytes |
38600704 |
38420024 |
38642574 |
40194048 |
Interestingly the data we get now for 5 collection proxies loaded is 1MB lower compared to having it with physics, but it is also still 1.8 MB over the other values. The memory added per collection is 0.36, meaning a 0.09 difference between with and without physics.
Package size
|
With |
Without |
Diff |
Diff -MB |
Android |
2801489 |
2491918 |
-309571 |
-0.3 |
iOS |
2619459 |
2263253 |
-356206 |
-0.35 |
macOS |
5408039 |
4230099 |
-1177940 |
-1.2 |
Other observations
profiler.get_memory_usage() is broken, doesn’t indicate that memory is released and only counts up. Making it only really reliable on build/app start.
If you have physics objects in your build and strips physics out the build will not be able to start but will not give any errors as far I noticed.
I should (but most likely won’t) test it out on android and/or iPhone to investigate if it is comparable with macOS.