summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-20 19:38:02 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-20 19:38:02 -0300
commit59154cccf9fcf814a21a2596993fb1b6777d3bb7 (patch)
tree4132620a9d924463dae4b64fea2dde68a14023e7 /core
parent28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6 (diff)
-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
Diffstat (limited to 'core')
-rw-r--r--core/io/file_access_network.cpp1
-rw-r--r--core/io/file_access_pack.cpp15
-rw-r--r--core/io/file_access_pack.h4
-rw-r--r--core/io/file_access_zip.cpp2
-rw-r--r--core/object.cpp15
-rw-r--r--core/register_core_types.cpp6
-rw-r--r--core/string_db.cpp18
7 files changed, 55 insertions, 6 deletions
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<String,PackedDir*>::Element *E=p_dir->subdirs.front();E;E=E->next())
+ _free_packed_dirs(E->get());
+ memdelete(p_dir);
+}
+
+PackedData::~PackedData() {
+
+ for(int i=0;i<sources.size();i++) {
+ memdelete(sources[i]);
+ }
+ _free_packed_dirs(root);
+}
+
//////////////////////////////////////////////////////////////////
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index aed0f5eb7c..5bf5ad012c 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -96,6 +96,8 @@ private:
static PackedData *singleton;
bool disabled;
+ void _free_packed_dirs(PackedDir *p_dir);
+
public:
void add_pack_source(PackSource* p_source);
@@ -111,6 +113,7 @@ public:
_FORCE_INLINE_ bool has_path(const String& p_path);
PackedData();
+ ~PackedData();
};
class PackSource {
@@ -119,6 +122,7 @@ public:
virtual bool try_open_pack(const String& p_path)=0;
virtual FileAccess* get_file(const String& p_path, PackedData::PackedFile* p_file)=0;
+ virtual ~PackSource() {}
};
class PackedSourcePCK : public PackSource {
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index 55c0dedad9..7a1b6454bd 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -150,7 +150,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
bool ZipArchive::try_open_pack(const String& p_name) {
- printf("opening pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
+ //printf("opening pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
if (p_name.extension().nocasecmp_to("zip") != 0 && p_name.extension().nocasecmp_to("pcz") != 0)
return false;
diff --git a/core/object.cpp b/core/object.cpp
index 0bc2b7ee41..07e24655c2 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -33,6 +33,7 @@
#include "message_queue.h"
#include "core_string_names.h"
#include "translation.h"
+#include "os/os.h"
#ifdef DEBUG_ENABLED
@@ -1728,8 +1729,20 @@ void ObjectDB::cleanup() {
GLOBAL_LOCK_FUNCTION;
if (instances.size()) {
-
+
WARN_PRINT("ObjectDB Instances still exist!");
+ if (OS::get_singleton()->is_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;i<STRING_TABLE_LEN;i++) {
while(_table[i]) {
_Data*d=_table[i];
- _table[i]=_table[i]->next;
+ 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();
}