Ummm.. I've found another issue
When running a debug build, exiting FSO can take ages, much longer than it does on latest trunk builds (which exit almost instantly in all cases). The length of time varies. e.g.
Kentauroi Race (course complete): normal speed exit
The Plunder (played for 1-2 mins, died): exit in approx 1 min
BP Massive Battle (played for maybe 30-45 sec): gave up waiting after 10-15 mins and forcibly killed FSO
I think massive battle would have eventually exited, as you could see changes occurring slowly, e.g. gdb reporting threads ending, the fs2_open.log closing message, etc. I also interrupted program execution with gdb and it was very slowly progressing - see below for stack traces taken at various times. As can be seen, the interruptions often occurred while execution was in _vm_free().
I used top to see the "resident set" memory usage - trunk builds report ~1GB of RAM usage, go_ever_faster builds report ~1.1-1.2GB - an extra 200 MB by itself shouldn't cause this sort of slowdown though.
I've run out of time to investigate further tonight, but I was thinking of trying to time the various functions in game_shutdown() to see if I can further narrow down what is taking so long. It'd also be good to know if anyone on Windows/OSX can reproduce this issue.
(gdb) bt
#0 0x000000000083566c in _vm_free (ptr=0x30df3f0, filename=0x939c73 "ship/ship.cpp", line=12894) at windows_stub/stubs.cpp:687
#1 0x0000000000797be9 in ship_close () at ship/ship.cpp:12894
#2 0x0000000000416de1 in game_shutdown () at freespace2/freespace.cpp:7335
#3 0x0000000000416a52 in game_main (cmdline=0x24d7bd0 "") at freespace2/freespace.cpp:7108
#4 0x0000000000416c3d in main (argc=1, argv=0x7fffffffe298) at freespace2/freespace.cpp:7236
(gdb)
(gdb) bt
#0 0x000000000083566c in _vm_free (ptr=0x2eb2130, filename=0x8a40f3 "./globalincs/vmallocator.h", line=62) at windows_stub/stubs.cpp:687
#1 0x0000000000448a0d in SCP_vm_allocator<char>::deallocate (this=0x7fffffffdeef, p=0x2eb2130 "\003") at ./globalincs/vmallocator.h:62
#2 0x0000000000447cae in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::_Rep::_M_destroy (this=0x2eb2130, __a=...) at /usr/include/c++/4.6/bits/basic_string.tcc:451
#3 0x00000000004473aa in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::_Rep::_M_dispose (this=0x2eb2130, __a=...) at /usr/include/c++/4.6/bits/basic_string.h:244
#4 0x0000000000446c1c in std::basic_string<char, std::char_traits<char>, SCP_vm_allocator<char> >::~basic_string (this=0x2ec4400, __in_chrg=<optimised out>) at /usr/include/c++/4.6/bits/basic_string.h:534
#5 0x00000000004be968 in game_snd::~game_snd (this=0x2ec4400, __in_chrg=<optimised out>) at ./sound/sound.h:39
#6 0x00000000004bf786 in SCP_vm_allocator<game_snd>::destroy (this=0xe8bb70, p=0x2ec4400) at ./globalincs/vmallocator.h:42
#7 0x00000000004befa6 in std::_Destroy<game_snd*, SCP_vm_allocator<game_snd> > (__first=0x2ec4400, __last=0x2ec5de0, __alloc=...) at /usr/include/c++/4.6/bits/stl_construct.h:145
#8 0x00000000004bf6dc in std::vector<game_snd, SCP_vm_allocator<game_snd> >::_M_erase_at_end (this=0xe8bb70, __pos=0x2ebcb10) at /usr/include/c++/4.6/bits/stl_vector.h:1255
#9 0x00000000004beef0 in std::vector<game_snd, SCP_vm_allocator<game_snd> >::clear (this=0xe8bb70) at /usr/include/c++/4.6/bits/stl_vector.h:1040
#10 0x00000000004be85a in gamesnd_close () at gamesnd/gamesnd.cpp:765
#11 0x0000000000416e51 in game_shutdown () at freespace2/freespace.cpp:7368
#12 0x0000000000416a52 in game_main (cmdline=0x24d7bd0 "") at freespace2/freespace.cpp:7108
#13 0x0000000000416c3d in main (argc=1, argv=0x7fffffffe298) at freespace2/freespace.cpp:7236
(gdb)
(gdb) bt
#0 0x00000000008356d0 in _vm_free (ptr=0x3b3c1b0, filename=0x8f07eb "model/modelread.cpp", line=4879) at windows_stub/stubs.cpp:686
#1 0x0000000000645408 in model_remove_bsp_collision_tree (tree_index=76) at model/modelread.cpp:4879
#2 0x00000000006359f6 in model_unload (modelnum=3, force=1) at model/modelread.cpp:240
#3 0x0000000000635c2d in model_free_all () at model/modelread.cpp:299
#4 0x0000000000416e5b in game_shutdown () at freespace2/freespace.cpp:7371
#5 0x0000000000416a52 in game_main (cmdline=0x24d7bd0 "") at freespace2/freespace.cpp:7108
#6 0x0000000000416c3d in main (argc=1, argv=0x7fffffffe298) at freespace2/freespace.cpp:7236
(gdb)
(gdb) bt
#0 0x000000000083566c in _vm_free (ptr=0xd88cb80, filename=0x8f07eb "model/modelread.cpp", line=4879) at windows_stub/stubs.cpp:687
#1 0x0000000000645408 in model_remove_bsp_collision_tree (tree_index=405) at model/modelread.cpp:4879
#2 0x00000000006359f6 in model_unload (modelnum=5, force=1) at model/modelread.cpp:240
#3 0x0000000000635c2d in model_free_all () at model/modelread.cpp:299
#4 0x0000000000416e5b in game_shutdown () at freespace2/freespace.cpp:7371
#5 0x0000000000416a52 in game_main (cmdline=0x24d7bd0 "") at freespace2/freespace.cpp:7108
#6 0x0000000000416c3d in main (argc=1, argv=0x7fffffffe298) at freespace2/freespace.cpp:7236
(gdb)
(gdb) bt
#0 0x000000000083566c in _vm_free (ptr=0x2673e30, filename=0x8dc311 "localization/localize.cpp", line=383) at windows_stub/stubs.cpp:687
#1 0x0000000000576b23 in lcl_xstr_close () at localization/localize.cpp:383
#2 0x00007ffff58d5921 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff58d59a5 in exit () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff58bb774 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x0000000000409e89 in _start ()
(gdb)
(gdb) bt
#0 0x000000000083566c in _vm_free (ptr=0x7fffd730fa20, filename=0x8ca0a0 "globalincs/fsmemory.cpp", line=19) at windows_stub/stubs.cpp:687
#1 0x00000000004c1c57 in operator delete (p=0x7fffd730fa20) at globalincs/fsmemory.cpp:19
#2 0x00000000006da7e8 in __gnu_cxx::new_allocator<__gnu_cxx::_Hashtable_node<std::pair<unsigned int const, collider_pair> > >::deallocate (this=0x116efe0, __p=0x7fffd730fa20) at /usr/include/c++/4.6/ext/new_allocator.h:98
#3 0x00000000006d9fb6 in __gnu_cxx::hashtable<std::pair<unsigned int const, collider_pair>, unsigned int, __gnu_cxx::hash<unsigned int>, std::_Select1st<std::pair<unsigned int const, collider_pair> >, std::equal_to<unsigned int>, std::allocator<collider_pair> >::_M_put_node (this=0x116efe0, __p=0x7fffd730fa20) at /usr/include/c++/4.6/backward/hashtable.h:297
#4 0x00000000006d9d3e in __gnu_cxx::hashtable<std::pair<unsigned int const, collider_pair>, unsigned int, __gnu_cxx::hash<unsigned int>, std::_Select1st<std::pair<unsigned int const, collider_pair> >, std::equal_to<unsigned int>, std::allocator<collider_pair> >::_M_delete_node (this=0x116efe0, __n=0x7fffd730fa20) at /usr/include/c++/4.6/backward/hashtable.h:619
#5 0x00000000006d9615 in __gnu_cxx::hashtable<std::pair<unsigned int const, collider_pair>, unsigned int, __gnu_cxx::hash<unsigned int>, std::_Select1st<std::pair<unsigned int const, collider_pair> >, std::equal_to<unsigned int>, std::allocator<collider_pair> >::clear (this=0x116efe0) at /usr/include/c++/4.6/backward/hashtable.h:1103
#6 0x00000000006d9053 in __gnu_cxx::hashtable<std::pair<unsigned int const, collider_pair>, unsigned int, __gnu_cxx::hash<unsigned int>, std::_Select1st<std::pair<unsigned int const, collider_pair> >, std::equal_to<unsigned int>, std::allocator<collider_pair> >::~hashtable (this=0x116efe0, __in_chrg=<optimised out>) at /usr/include/c++/4.6/backward/hashtable.h:357
#7 0x00000000006daf24 in __gnu_cxx::hash_map<unsigned int, collider_pair, __gnu_cxx::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<collider_pair> >::~hash_map (this=0x116efe0, __in_chrg=<optimised out>) at /usr/include/c++/4.6/ext/hash_map:84
#8 0x00007ffff58d5921 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#9 0x00007ffff58d59a5 in exit () from /lib/x86_64-linux-gnu/libc.so.6
#10 0x00007ffff58bb774 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#11 0x0000000000409e89 in _start ()
(gdb)
(that last backtrace really looks odd...)