From 59154cccf9fcf814a21a2596993fb1b6777d3bb7 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 20 Apr 2015 19:38:02 -0300 Subject: -Changed Godot exit to be clean. -Added more debug information on memory cleanliness on exit (if run with -v) -Fixed several memory leaks, fixes #1731, fixes #755 --- core/io/file_access_network.cpp | 1 + core/io/file_access_pack.cpp | 15 +++++++++++++++ core/io/file_access_pack.h | 4 ++++ core/io/file_access_zip.cpp | 2 +- core/object.cpp | 15 ++++++++++++++- core/register_core_types.cpp | 6 ++++-- core/string_db.cpp | 18 ++++++++++++++++-- 7 files changed, 55 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index a5ec05c35e..850e055129 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -254,6 +254,7 @@ FileAccessNetworkClient::~FileAccessNetworkClient() { quit=true; sem->post(); Thread::wait_to_finish(thread); + memdelete(thread); } memdelete(blockrequest_mutex); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 15435a8b61..bf1211f2b3 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -107,6 +107,21 @@ PackedData::PackedData() { add_pack_source(memnew(PackedSourcePCK)); } +void PackedData::_free_packed_dirs(PackedDir *p_dir) { + + for (Map::Element *E=p_dir->subdirs.front();E;E=E->next()) + _free_packed_dirs(E->get()); + memdelete(p_dir); +} + +PackedData::~PackedData() { + + for(int i=0;iis_stdout_verbose()) { + const uint32_t *K=NULL; + while((K=instances.next(K))) { + + String node_name; + if (instances[*K]->is_type("Node")) + node_name=" - Node Name: "+String(instances[*K]->call("get_name")); + if (instances[*K]->is_type("Resoucre")) + node_name=" - Resource Name: "+String(instances[*K]->call("get_name"))+" Path: "+String(instances[*K]->call("get_path")); + print_line("Leaked Instance: "+String(instances[*K]->get_type())+":"+itos(*K)+node_name); + } + } } instances.clear(); instance_checks.clear(); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 70e2ec191b..8754946bb1 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -205,12 +205,14 @@ void unregister_core_types() { if (ip) memdelete(ip); + + ObjectDB::cleanup(); + unregister_variant_methods(); - CoreStringNames::free(); ObjectTypeDB::cleanup(); ResourceCache::clear(); - ObjectDB::cleanup(); + CoreStringNames::free(); StringName::cleanup(); if (_global_mutex) { diff --git a/core/string_db.cpp b/core/string_db.cpp index 8761551fe2..57fdd6e70f 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "string_db.h" #include "print_string.h" - +#include "os/os.h" StaticCString StaticCString::create(const char *p_ptr) { StaticCString scs; scs.ptr=p_ptr; return scs; } @@ -55,15 +55,29 @@ void StringName::setup() { void StringName::cleanup() { _global_lock(); + int lost_strings=0; for(int i=0;inext; + lost_strings++; + if (OS::get_singleton()->is_stdout_verbose()) { + + if (d->cname) { + print_line("Orphan StringName: "+String(d->cname)); + } else { + print_line("Orphan StringName: "+String(d->name)); + } + } + + _table[i]=_table[i]->next; memdelete(d); } } + if (OS::get_singleton()->is_stdout_verbose() && lost_strings) { + print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit."); + } _global_unlock(); } -- cgit v1.2.3