Godot Version
Godot 3.5
Question
Hello, I’m trying to determine how much memory my project is using. Specifically, I’m looking to compare the memory usage of different file formats, so I modified the following function:
RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache, Error *r_error)
Within this function, I implemented something like this:
Performance::get_singleton()->CheckMemSizeBeforeLoad();
RES res = _load(path, local_path, p_type_hint, p_no_cache, r_error);
Performance::get_singleton()->CheckMemSizeAfterLoad(path.get_extension());
Using this, I gathered some data, but the results seem a bit off. To improve accuracy, I added a check for whether the resource is already cached:
Performance::get_singleton()->CheckMemSizeBeforeLoad();
ResourceCache::lock.read_unlock();
_remove_from_loading_map(local_path);
Performance::get_singleton()->CheckMemSizeAfterLoad(path.get_extension());
With this modification, the data appears more consistent when compared to other systems I have in the project. However, .tscn files show as occupying no memory, which seems incorrect.
How i could know how to correctly measure memory usage for different resource types and whether there is a better approach for calculating this?