-
Notifications
You must be signed in to change notification settings - Fork 83
[GEN][ZH] Fix Memory Manager initialization issues (old) #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GEN][ZH] Fix Memory Manager initialization issues (old) #1236
Conversation
Thanks for investigating this! Your change does indeed fix the issue, but it also adds a lot of complexity. Adding yet another phase to commandline parsing is not the right way to go in my opinion (I think even two is one too many). I think we can fix this by simply moving the |
This was also one of my tries to fix this, but it was not the right approach, because there is also at least one DEBUG_ASSERTCRASH (which implies logging when hit) in the memory manager initialization. Plus client instance initialization also needs to be done before debug logging and therefore without new/delete, because the instance id affects the name of the log file. This is quite a bit complicated order of initialization but this change fixes it. Order: Command Line parse (parts) MallocAllocator is needed regardless. There will always be things that want to bypass Memory Manager in rare special cases. Memory Manager itself needs to bypass new/delete :-) |
Where is this DEBUG_ASSERTCRASH? |
DynamicMemoryAllocator::init |
We can move Memory Manager first above all but then need to never use logging in it. We could use |
I looked deeper, there are more asserts in MemoryPoolFactory::createMemoryPool Moving logging behind memory manager will lose logging/asserting for all of this. |
So yeah we need to decide, is allocation (using new) more important everywhere, or the ability to log/assert everywhere? |
What we can try to do is make DEBUG_CRASH more usable when Debug was not yet initialized. Logging nothing. Do you want that? |
I am working on a new change. Will be done later. |
Ah, you are right, I must have missed that. Hm.
Yes, that sounds pretty good. Another alternative might be to remove/replace all globals that allocate, not sure if that's feasable. |
Never mind, there are so many globals... |
Done: #1275 |
Obsoleted |
This change fixes Memory Manager initialization issues.
Problems identified:
ClientInstance::initialize
andCommandLine::parseCommandLineForStartup
both used 'new' allocator before the Memory Manager was initialized, in both Debug and Release. This caused the Memory Manager to actually be created twice, and trigger 1 assert on game launch and 1 assert on game quit.This is now fixed by fixing initialization ordering and preventing some allocations with 'new'.
This change also uses the
stl::malloc_allocator
that was added to the pending Pull Request #1066.TODO