pthread_t main_thread;
#endif
+#ifdef HAVE_NS
+/* NS autrelease pool, for memory management. */
+static void *ns_pool;
+#endif
+
+
/* Handle bus errors, invalid instruction, etc. */
#ifndef FLOAT_CATCH_SIGILL
= argmatch (argv, argc, "-nsl", "--no-site-lisp", 11, NULL, &skip_args);
#ifdef HAVE_NS
- ns_alloc_autorelease_pool ();
+ ns_pool = ns_alloc_autorelease_pool ();
if (!noninteractive)
{
#ifdef NS_IMPL_COCOA
shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
+#ifdef HAVE_NS
+ ns_release_autorelease_pool (ns_pool);
+#endif
+
/* If we have an auto-save list file,
kill it because we are exiting Emacs deliberately (not crashing).
Do it after shut_down_emacs, which does an auto-save. */