debug option to track Entities (#2526)
* debug option to track Entities Set FILAMENT_UTILS_TRACK_ENTITIES to true when building libutils to activate entity tracking. This adds two public methods: getActiveEntities() and dumpActiveEntities() the later displays the stack trace of where the remaining entities were allocated. This is useful for tracking leaks. * Update libs/utils/include/utils/EntityManager.h Co-authored-by: Philip Rideout <philiprideout@gmail.com> Co-authored-by: Philip Rideout <philiprideout@gmail.com>
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <utils/EntityManager.h>
|
||||
|
||||
#include "EntityManagerImpl.h"
|
||||
|
||||
namespace utils {
|
||||
@@ -28,6 +30,8 @@ EntityManager::~EntityManager() {
|
||||
delete [] mGens;
|
||||
}
|
||||
|
||||
EntityManager::Listener::~Listener() noexcept = default;
|
||||
|
||||
EntityManager& EntityManager::get() noexcept {
|
||||
// note: we leak the EntityManager because it's more important that it survives everything else
|
||||
// the leak is really not a problem because the process is terminating anyways.
|
||||
@@ -51,4 +55,15 @@ void EntityManager::unregisterListener(EntityManager::Listener* l) noexcept {
|
||||
static_cast<EntityManagerImpl *>(this)->unregisterListener(l);
|
||||
}
|
||||
|
||||
#if FILAMENT_UTILS_TRACK_ENTITIES
|
||||
std::vector<Entity> EntityManager::getActiveEntities() const {
|
||||
return static_cast<EntityManagerImpl const *>(this)->getActiveEntities();
|
||||
}
|
||||
|
||||
void EntityManager::dumpActiveEntities(utils::io::ostream& out) const {
|
||||
static_cast<EntityManagerImpl const *>(this)->dumpActiveEntities(out);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace utils
|
||||
|
||||
Reference in New Issue
Block a user