Skip to content
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

Potential memory leak in worldserver #20240

Open
PaoloBenigni opened this issue Oct 18, 2024 · 1 comment
Open

Potential memory leak in worldserver #20240

PaoloBenigni opened this issue Oct 18, 2024 · 1 comment

Comments

@PaoloBenigni
Copy link

Current Behaviour

The ram consumption of the worldserver is continually increasing even when players have never logged into the system.
Picture1

Analysis of the heap memory shows that the big spikes in memory usage are related to the map manager.
MMapMgr.cpp, line 174 (C:\Temp\source\azerothcore-wotlk\src\common\Collision\Management\MMapMgr.cpp)

However what seems unusual is that there is an ever increasing usage of memory from the RandomMovementGenerator.
RandomMovementGenerator.cpp, line 73 (C:\Temp\source\azerothcore-wotlk\src\server\game\Movement\MovementGenerators\RandomMovementGenerator.cpp)
The final number of hits in memory for this was 223,300. I am unsure if this is expected behavior, but was expecting that there would be a 1:1 relationship between creatures and generators, or at least that it wouldnt increase after everything was properly loaded.

Here is the full stack trace.

ntdll.dll!RtlAllocateHeap 00007ffd2801a9a0		
ucrtbase.dll!malloc_base + 0x30 bytes 00007ffd257ffde0		
worldserver.exe!operator new Line 36 + 0x3 bytes 00007ff68d838f36	D:\a\_work\1\s\src\vctools\crt\vcstartup\src\heap\new_scalar.cpp, line 36	
worldserver.exe!RandomMovementGenerator<Creature>::_setRandomLocation Line 73 + 0x79 bytes 00007ff68d5be849	C:\Temp\source\azerothcore-wotlk\src\server\game\Movement\MovementGenerators\RandomMovementGenerator.cpp, line 73	
worldserver.exe!RandomMovementGenerator<Creature>::DoUpdate Line 298 + 0x6 bytes 00007ff68d5bdc2a	C:\Temp\source\azerothcore-wotlk\src\server\game\Movement\MovementGenerators\RandomMovementGenerator.cpp, line 298	
worldserver.exe!MotionMaster::UpdateMotion Line 114 + 0x17 bytes 00007ff68d1ab0dc	C:\Temp\source\azerothcore-wotlk\src\server\game\Movement\MotionMaster.cpp, line 114	
worldserver.exe!Unit::Update Line 516 + 0x9 bytes 00007ff68d046e5d	C:\Temp\source\azerothcore-wotlk\src\server\game\Entities\Unit\Unit.cpp, line 516	
worldserver.exe!Creature::Update Line 720 + 0x5 bytes 00007ff68d11e5dd	C:\Temp\source\azerothcore-wotlk\src\server\game\Entities\Creature\Creature.cpp, line 720	
worldserver.exe!Acore::ObjectUpdater::Visit<Creature> Line 366 + 0x5 bytes 00007ff68d397eb0	C:\Temp\source\azerothcore-wotlk\src\server\game\Grids\Notifiers\GridNotifiers.cpp, line 366	
worldserver.exe!VisitorHelper<Acore::ObjectUpdater,Creature,TypeList<DynamicObject,TypeList<Corpse,TypeNull> > > Line 49 00007ff68d0ee790	C:\Temp\source\azerothcore-wotlk\src\common\Dynamic\TypeContainerVisitor.h, line 49	
worldserver.exe!Map::Visit<Acore::ObjectUpdater,TypeMapContainer<TypeList<GameObject,TypeList<Creature,TypeList<DynamicObject,TypeList<Corpse,TypeNull> > > > > > Line 883 + 0x21 bytes 00007ff68d0ee607	C:\Temp\source\azerothcore-wotlk\src\server\game\Maps\Map.h, line 883	
worldserver.exe!Map::VisitNearbyCellsOf Line 723 + 0x3 bytes 00007ff68d106686	C:\Temp\source\azerothcore-wotlk\src\server\game\Maps\Map.cpp, line 723	
worldserver.exe!Map::Update Line 802 + 0x24 bytes 00007ff68d105a5f	C:\Temp\source\azerothcore-wotlk\src\server\game\Maps\Map.cpp, line 802	
worldserver.exe!MapUpdateRequest::call Line 44 + 0x11 bytes 00007ff68d52287f	C:\Temp\source\azerothcore-wotlk\src\server\game\Maps\MapUpdater.cpp, line 44	
worldserver.exe!MapUpdater::WorkerThread Line 156 + 0x6 bytes 00007ff68d5223fc	C:\Temp\source\azerothcore-wotlk\src\server\game\Maps\MapUpdater.cpp, line 156	
worldserver.exe!std::thread::_Invoke<std::tuple<void (__cdecl MapUpdater::*)(void),MapUpdater *>,0,1> Line 60 + 0x3 bytes 00007ff68d521ccc	C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\thread, line 60	
ucrtbase.dll!configthreadlocale + 0x8c bytes 00007ffd25811bac		
kernel32.dll!BaseThreadInitThunk + 0xe bytes 00007ffd264a736e		
ntdll.dll!RtlUserThreadStart + 0x1b bytes 00007ffd2803cc8b		

Expected Blizzlike Behaviour

No memory leaks. (Or maybe blizz had it anyway!)

Source

No response

Steps to reproduce the problem

  1. Build
  2. Start worldserver
  3. wait.
    (Note memory plotting was performed with perfmon in windows, and heap analysis was done with deleaker.)

Extra Notes

None

AC rev. hash/commit

AC> server debug
AzerothCore rev. 9182e97 2024-10-16 15:01:01 +0000 (master branch) (Win64, RelWithDebInfo, Static)
Connected players: 0. Characters in world: 0.
Connection peak: 0.
Server uptime: 1 minute(s) 52 second(s)
Update time diff: 2ms. Last 1 diffs summary:
|- Mean: 2ms
|- Median: 2ms
|- Percentiles (95, 99, max): 2ms, 2ms, 2ms
Using SSL version: OpenSSL 3.3.2 3 Sep 2024 (library: OpenSSL 3.3.2 3 Sep 2024)
Using Boost version: 1.81.0
Using CMake version: 3.30.5
Using MySQL version: 80402
Found MySQL Executable: C:/Program Files/MySQL/MySQL Server 8.4/bin/mysql.exe
Compiled on: Windows 10.0.19045
Worldserver listening connections on port %hu
Realmlist (Realm Id: 1) configured in port 8085
VMAPs status: Enabled. LineOfSight: true, getHeight: true, indoorCheck: true
MMAPs status: Enabled
maps directory located in C:/Temp/source/build/bin/RelWithDebInfo/data/maps. Total size: 291014951 bytes
vmaps directory located in C:/Temp/source/build/bin/RelWithDebInfo/data/vmaps. Total size: 658130721 bytes
mmaps directory located in C:/Temp/source/build/bin/RelWithDebInfo/data/mmaps. Total size: 2192910844 bytes
Default DBC locale: enUS.
All available DBC locales: enUS
Using World DB: ACDB 335.12-dev
Latest LoginDatabase update: 2024_01_20_00.sql
Latest CharacterDatabase update: 2024_09_22_00.sql
Latest WorldDatabase update: 2024_10_16_03.sql
LoginDatabase queue size: 0
CharacterDatabase queue size: 0
WorldDatabase queue size: 0
No modules are enabled

Operating system

Windows 10

Custom changes or Modules

None

@Ovahlord
Copy link
Contributor

Ovahlord commented Oct 18, 2024

grafik
probably leaking memory here. The pathgenerator is a raw pointer that's allocated once but never properly detroyed. This needs to be converted to a unique_ptr. It's only being destoryed for creatures. If a player would use it, it would leak the path generator every single time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants