In both cases the game exits at normal speed (i.e. <1 sec). In addition, the in-mission framerate is also faster - approx 6fps worst case compared with approx 4 secs per frame worst case.
As I said, new collision code is using STL hash map. STL doesn't run very well in Debug I noticed which has gradually been problematic as the code base continues to use STL containers in more parts of the code. Probably something that warrants us looking into ways to get STL containers faster in debug. But that's not within the scope of this thread.
OK - FSO running slow in debug isn't a bit deal to me (it's expected behaviour, right?

), waiting 15 mins for it to exit kinda is though - although I haven't really seen any drawbacks to just killing it off - so that's probably an OK workaround. It'll probably confuse a normal user trying to generate a debug log though.
I suspect that the function below is causing the problem, the entire file is wrapped in an #ifdef SCP_UNIX so you probably won't have seen the issue on Windows. There's a linked list (RamTable) keeping track of all the allocated memory and its size, with the old collision code RamTable has a max size of approx 19,000 entries, with the new collision code I've seen it as high as approx 263,000 - and that function has a woefully slow way of finding the pointer of memory it's looking for. When the list is around 263,000 entries in size, it was taking approx a minute to remove 1000 entries from the list - obviously it gets faster and faster as you remove more and more entries. I'll see if I can re-factor it to be more efficient when dealing with large number of entries.
tl;dr doesn't seem to be a problem with the new collision code itself, it's just triggering a different issue in debug.
#ifndef NDEBUG
void _vm_free( void *ptr, char *filename, int line )
#else
void _vm_free( void *ptr )
#endif
{
if ( !ptr ) {
#ifndef NDEBUG
mprintf(("Why are you trying to free a NULL pointer? [%s(%d)]\n", clean_filename(filename), line));
#else
mprintf(("Why are you trying to free a NULL pointer?\n"));
#endif
return;
}
#ifndef NDEBUG
RAM *item = RamTable;
RAM **mark = &RamTable;
while (item != NULL) {
if (item->addr == (ptr_u)ptr) {
RAM *tmp = item;
*mark = item->next;
TotalRam -= tmp->size;
free(tmp);
break;
}
mark = &(item->next);
item = item->next;
}
#endif // !NDEBUG
free(ptr);
}