Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 434)
+++ /trunk/xcache.c	(revision 435)
@@ -1657,5 +1657,5 @@
 	int i;
 
-	if (XG(internal_function_table).nTableSize == 0) {
+	if (!XG(internal_table_copied)) {
 		zend_function tmp_func;
 		xc_cest_t tmp_cest;
@@ -1669,4 +1669,6 @@
 		zend_hash_copy(&XG(internal_function_table), CG(function_table), (copy_ctor_func_t) function_add_ref, &tmp_func, sizeof(tmp_func));
 		zend_hash_copy(&XG(internal_class_table), CG(class_table), (copy_ctor_func_t) xc_zend_class_add_ref, &tmp_cest, sizeof(tmp_cest));
+
+		XG(internal_table_copied) = 1;
 	}
 	if (xc_php_hcache.size && !XG(php_holds)) {
@@ -1718,5 +1720,4 @@
 	zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);
 	zend_hash_init_ex(&xcache_globals->internal_class_table,    1, NULL, NULL, 1, 0);
-
 }
 /* }}} */
@@ -1747,6 +1748,8 @@
 	}
 
-	zend_hash_destroy(&xcache_globals->internal_function_table);
-	zend_hash_destroy(&xcache_globals->internal_class_table);
+	if (XG(internal_table_copied)) {
+		zend_hash_destroy(&xcache_globals->internal_function_table);
+		zend_hash_destroy(&xcache_globals->internal_class_table);
+	}
 }
 /* }}} */
Index: /trunk/xcache_globals.h
===================================================================
--- /trunk/xcache_globals.h	(revision 434)
+++ /trunk/xcache_globals.h	(revision 435)
@@ -20,4 +20,5 @@
 	HashTable internal_function_table;
 	HashTable internal_class_table;
+	zend_bool internal_table_copied;
 ZEND_END_MODULE_GLOBALS(xcache)
 
