From 9f9fed4693da09a6a880aff46eb6871bd408ba08 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 20 Nov 2016 07:52:52 -0600 Subject: [PATCH 01/13] memory manager cleanup and removal --- CMakeLists.txt | 2 +- .../src/shared/DatabaseProcess.cpp | 11 --------- .../serverDatabase/src/shared/Persister.cpp | 17 +++++--------- .../serverDatabase/src/shared/Snapshot.cpp | 8 ++++--- .../serverDatabase/src/shared/Snapshot.h | 4 ++-- .../src/shared/TaskSaveSnapshot.cpp | 4 +--- .../src/shared/TaskSaveSnapshot.h | 2 +- .../console/ConsoleCommandParserServer.cpp | 3 +-- .../serverMetrics/src/shared/MetricsData.cpp | 7 ------ .../src/shared/ScriptMethodsDebug.cpp | 3 --- .../src/shared/ZlibCompressor.cpp | 5 ++-- .../src_oci/OciSession.cpp | 23 +------------------ .../sharedDebug/src/shared/InstallTimer.cpp | 5 +--- .../sharedDebug/src/shared/InstallTimer.h | 1 - .../src/linux/SetupSharedFoundation.cpp | 3 --- .../src/linux/OsNewDel.cpp | 4 ++-- .../sharedMemoryManager/src/linux/OsNewDel.h | 3 +++ .../src/shared/MemoryManager.cpp | 2 +- .../src/shared/CachedFileManager.cpp | 6 ----- .../src/shared/core/SetupSharedXml.cpp | 2 +- .../src/shared/tree/XmlTreeDocumentList.cpp | 9 -------- .../src/shared/buffers/ObjvarBuffer.cpp | 6 ----- .../src/shared/buffers/ObjvarBuffer.h | 11 ++++++++- .../src/shared/core/SwgSnapshot.cpp | 4 +--- .../src/shared/core/SwgSnapshot.h | 1 - 25 files changed, 39 insertions(+), 107 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db32cdaa..86432ad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ elseif(UNIX) # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") #endif() - add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_USING_STL -D__STL_NO_BAD_ALLOC -D_GNU_SOURCE -D_XOPEN_SOURCE=500) + add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500) endif() add_subdirectory(external) diff --git a/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp b/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp index 4df57236..f5dcb25c 100755 --- a/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp +++ b/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp @@ -197,7 +197,6 @@ void DatabaseProcess::run(void) static bool shouldSleep = ConfigServerDatabase::getShouldSleep(); bool idle=false; int loopcount=0; - float nextMemoryReportTime=0; float nextQueryCountTime=0; LOG("ServerStartup",("DatabaseServer starting")); @@ -240,16 +239,6 @@ void DatabaseProcess::run(void) PROFILER_AUTO_BLOCK_DEFINE("NetworkHandler::update"); NetworkHandler::update(); } - nextMemoryReportTime-=updateTime; - if (nextMemoryReportTime < 0) - { -#ifndef _WIN32 - LOG("DatabaseMemory",("Bytes used: %lu (VmSize %dK) Open allocations: %d Total Allocations %d",MemoryManager::getCurrentNumberOfBytesAllocated(static_cast(Os::getProcessId())),MemoryManager::getProcessVmSizeKBytes(static_cast(Os::getProcessId())),MemoryManager::getCurrentNumberOfAllocations(),MemoryManagerNamespace::ms_allocateCalls)); -#else - LOG("DatabaseMemory",("Bytes used: %lu Open allocations: %d Total Allocations %d",MemoryManager::getCurrentNumberOfBytesAllocated(static_cast(Os::getProcessId())),MemoryManager::getCurrentNumberOfAllocations(),MemoryManagerNamespace::ms_allocateCalls)); -#endif - nextMemoryReportTime=10; - } nextQueryCountTime-=updateTime; if (nextQueryCountTime < 0) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 25887d15..218e47f2 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -336,10 +336,10 @@ void Persister::startSave(void) taskQueue->asyncRequest(new TaskSaveSnapshot(i->second)); } for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) - { - m_savingSnapshots.push_back(i->second); - taskQueue->asyncRequest(new TaskSaveSnapshot(i->second)); - } + { + m_savingSnapshots.push_back(i->second); + taskQueue->asyncRequest(new TaskSaveSnapshot(i->second)); + } // nothing changed so send a complete message for the shutdown process if( m_savingSnapshots.empty() ) @@ -602,10 +602,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { - delete *i; - i = m_savingSnapshots.erase(i, m_savingSnapshots.end()); - *i = nullptr; - + m_savingSnapshots.erase(i, m_savingSnapshots.end()); if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { int saveTime = Clock::timeMs() - m_saveStartTime; @@ -637,9 +634,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); - delete *j; - *j = nullptr; - j = m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } diff --git a/engine/server/library/serverDatabase/src/shared/Snapshot.cpp b/engine/server/library/serverDatabase/src/shared/Snapshot.cpp index ab3203bc..768d8f99 100755 --- a/engine/server/library/serverDatabase/src/shared/Snapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/Snapshot.cpp @@ -42,14 +42,16 @@ Snapshot::~Snapshot() for (LocatorListType::iterator i=m_locatorList.begin(); i!=m_locatorList.end(); ++i) { delete *i; - *i=0; + *i = nullptr; } - for (CustomStepListType::iterator j=m_customStepList.begin(); j!=m_customStepList.end(); ++j) + for (CustomStepListType::iterator j=m_customStepList.begin(); j!=m_customStepList.end(); ++j) { delete *j; + *j = nullptr; + } ++ms_deletionCount; - LOG("Snapshot",("Deleted snapshot. %i outstanding, %i created, %i deleted", ms_creationCount-ms_deletionCount,ms_creationCount,ms_deletionCount)); + LOG("Snapshot",("Deleted snapshot. %i outstanding, %i created, %i deleted", ms_creationCount-ms_deletionCount,ms_creationCount,ms_deletionCount)); } // ---------------------------------------------------------------------- diff --git a/engine/server/library/serverDatabase/src/shared/Snapshot.h b/engine/server/library/serverDatabase/src/shared/Snapshot.h index 65cc879a..a5876cd2 100755 --- a/engine/server/library/serverDatabase/src/shared/Snapshot.h +++ b/engine/server/library/serverDatabase/src/shared/Snapshot.h @@ -79,8 +79,8 @@ public: virtual void startLoadAfterSaveComplete() =0; protected: - typedef std::vector BufferListType; - typedef std::vector LocatorListType; + typedef std::vector BufferListType; + typedef std::vector LocatorListType; typedef std::vector CustomStepListType; /** diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp index 4207b8b1..2222b250 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp @@ -10,12 +10,10 @@ #include "serverDatabase/Persister.h" #include "serverDatabase/Snapshot.h" -#include "sharedFoundation/NetworkIdArchive.h" //TODO: Windows build breaks without this. Why? Makes no sense. // ====================================================================== -TaskSaveSnapshot::TaskSaveSnapshot(Snapshot *snapshot) : - m_snapshot(snapshot) +TaskSaveSnapshot::TaskSaveSnapshot(Snapshot *snapshot) : m_snapshot(snapshot) { } diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.h b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.h index b87f532c..81fd76a8 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.h +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.h @@ -22,7 +22,7 @@ class TaskSaveSnapshot : public DB::TaskRequest TaskSaveSnapshot(Snapshot *snapshot); bool process(DB::Session *session); void onComplete(); - + private: Snapshot *m_snapshot; }; diff --git a/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserServer.cpp b/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserServer.cpp index 0e2e490f..b65eb5e7 100755 --- a/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserServer.cpp +++ b/engine/server/library/serverGame/src/shared/console/ConsoleCommandParserServer.cpp @@ -96,7 +96,6 @@ static const CommandParser::CmdInfo cmds[] = {"error", 1, "", "Display an error message."}, {"getPlanetId", 0, "[planet]", "Get the current obj_id of the planet for this server (or for the specified planet)."}, {"memUsage", 0, "", "Query memory usage statistics."}, - {"memoryReport", 0, "", "Dump memory manager (call MemoryManager::report())."}, {"dumpMemToFile", 2, " ", "Dump memory report to file on server, can be called to dump all allocations or only known leaks."}, {"clock", 0, "", "Query clock statistics."}, {"releaseAuth", 1, "", "Release Authority for object with oid."}, @@ -3518,4 +3517,4 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const return true; } -// ====================================================================== \ No newline at end of file +// ====================================================================== diff --git a/engine/server/library/serverMetrics/src/shared/MetricsData.cpp b/engine/server/library/serverMetrics/src/shared/MetricsData.cpp index 20ffb1fc..c5f0d801 100755 --- a/engine/server/library/serverMetrics/src/shared/MetricsData.cpp +++ b/engine/server/library/serverMetrics/src/shared/MetricsData.cpp @@ -77,13 +77,6 @@ const GameNetworkMessage & MetricsData::getDataToSend() void MetricsData::updateData() { - m_data[m_memoryUtilization].m_value = static_cast(MemoryManager::getCurrentNumberOfBytesAllocated(static_cast(Os::getProcessId())) / 1024); - m_data[m_memoryUtilizationNoLeakTest].m_value = static_cast(MemoryManager::getCurrentNumberOfBytesAllocatedNoLeakTest() / 1024); - m_data[m_memoryAllocated].m_value = MemoryManager::getSystemMemoryAllocatedMegabytes() * 1024; -#ifndef _WIN32 - m_data[m_memoryVmSize].m_value = MemoryManager::getProcessVmSizeKBytes(static_cast(Os::getProcessId())); -#endif - //deal with frame time float frameTime = Clock::frameTime() * 1000; float oldFrameTime = m_frameTimeHistory[m_frameTimeHistoryIndex]; diff --git a/engine/server/library/serverScript/src/shared/ScriptMethodsDebug.cpp b/engine/server/library/serverScript/src/shared/ScriptMethodsDebug.cpp index 6769ff57..396a27b2 100755 --- a/engine/server/library/serverScript/src/shared/ScriptMethodsDebug.cpp +++ b/engine/server/library/serverScript/src/shared/ScriptMethodsDebug.cpp @@ -354,7 +354,6 @@ void JNICALL ScriptMethodsDebugNamespace::profilerStopAccum(JNIEnv *env, jobject void JNICALL ScriptMethodsDebugNamespace::disableGameMemoryDump(JNIEnv *env, jobject self) { UNREF(self); - MemoryManager::setReportAllocations(false); NetworkIdManager::setReportObjectLeaks(false); } @@ -363,7 +362,6 @@ void JNICALL ScriptMethodsDebugNamespace::disableGameMemoryDump(JNIEnv *env, job void JNICALL ScriptMethodsDebugNamespace::debugMemoryReport(JNIEnv *env, jobject self) { UNREF(self); - MemoryManager::debugReport(); } // ---------------------------------------------------------------------- @@ -371,7 +369,6 @@ void JNICALL ScriptMethodsDebugNamespace::debugMemoryReport(JNIEnv *env, jobject void JNICALL ScriptMethodsDebugNamespace::debugMemoryReportMap(JNIEnv *env, jobject self) { UNREF(self); - MemoryManager::debugReportMap(); } // ---------------------------------------------------------------------- diff --git a/engine/shared/library/sharedCompression/src/shared/ZlibCompressor.cpp b/engine/shared/library/sharedCompression/src/shared/ZlibCompressor.cpp index 8a0515a8..23286d80 100755 --- a/engine/shared/library/sharedCompression/src/shared/ZlibCompressor.cpp +++ b/engine/shared/library/sharedCompression/src/shared/ZlibCompressor.cpp @@ -11,7 +11,6 @@ #include "sharedDebug/DebugFlags.h" #include "sharedFoundation/ExitChain.h" -#include "sharedMemoryManager/MemoryManager.h" #include "sharedSynchronization/Mutex.h" #include "zlib.h" @@ -88,10 +87,10 @@ void ZlibCompressorNamespace::freeWrapper(voidpf opaque, voidpf address) void ZlibCompressor::install(int numberOfParallelThreads) { - if (numberOfParallelThreads <= 1 || MemoryManager::getLimit() < 260) + if (numberOfParallelThreads <= 1) ms_poolElementCount = 5; else - if (numberOfParallelThreads <= 2 || MemoryManager::getLimit() < 375) + if (numberOfParallelThreads <= 2) ms_poolElementCount = 10; else ms_poolElementCount = 15; diff --git a/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp b/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp index e7e7bc66..eb6e9d2c 100755 --- a/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp +++ b/engine/shared/library/sharedDatabaseInterface/src_oci/OciSession.cpp @@ -41,7 +41,7 @@ static dvoid *mallocHook(dvoid *, size_t size) static dvoid *reallocHook(dvoid *, dvoid *memptr, size_t newsize) { - return reinterpret_cast(MemoryManager::reallocate(memptr, newsize)); + return reinterpret_cast(realloc(memptr, newsize)); } // ---------------------------------------------------------------------- @@ -81,26 +81,6 @@ bool DB::OCISession::connect() // so that each session can be used by a different thread concurrently. sword result=OCI_ERROR; - if (m_server->getUseMemoryManager()) - { - result = OCIEnvCreate(&envhp, // OCIEnv **envhpp, - OCI_THREADED | OCI_OBJECT, //ub4 mode, //TODO: do we have to use threaded mode? - 0, // CONST dvoid *ctxp, - &mallocHook, // CONST dvoid *(*malocfp) - // (dvoid *ctxp, - // size_t size), - &reallocHook, // CONST dvoid *(*ralocfp) - // (dvoid *ctxp, - // dvoid *memptr, - // size_t newsize), - &freeHook, // CONST void (*mfreefp) - // (dvoid *ctxp, - // dvoid *memptr)) - 0, //size_t xtramemsz, - 0 ); //dvoid **usrmempp ); - } - else - { result = OCIEnvCreate(&envhp, // OCIEnv **envhpp, OCI_THREADED | OCI_OBJECT, //ub4 mode, //TODO: do we have to use threaded mode? 0, // CONST dvoid *ctxp, @@ -117,7 +97,6 @@ bool DB::OCISession::connect() 0, //size_t xtramemsz, 0 ); //dvoid **usrmempp ); - } FATAL(result != OCI_SUCCESS,("OciEnvCreate failed with error code %hd",result)); // Create error handle. diff --git a/engine/shared/library/sharedDebug/src/shared/InstallTimer.cpp b/engine/shared/library/sharedDebug/src/shared/InstallTimer.cpp index 80e21bc9..81fcce87 100755 --- a/engine/shared/library/sharedDebug/src/shared/InstallTimer.cpp +++ b/engine/shared/library/sharedDebug/src/shared/InstallTimer.cpp @@ -39,8 +39,7 @@ void InstallTimer::checkConfigFile() InstallTimer::InstallTimer(char const * description) : m_description(description), - m_performanceTimer(), - m_startingNumberOfBytesAllocated(MemoryManager::getCurrentNumberOfBytesAllocated()) + m_performanceTimer() { NOT_NULL(m_description); m_performanceTimer.start(); @@ -61,9 +60,7 @@ void InstallTimer::manualExit() if (m_description) { m_performanceTimer.stop(); - unsigned long const endingNumberOfBytesAllocated = MemoryManager::getCurrentNumberOfBytesAllocated(); --ms_indent; - REPORT_LOG_PRINT(ms_enabled, ("InstallTimer:%*c%6.4f %d %s\n", ms_indent * 2, ' ', m_performanceTimer.getElapsedTime(), static_cast(endingNumberOfBytesAllocated - m_startingNumberOfBytesAllocated), m_description)); m_description = nullptr; } } diff --git a/engine/shared/library/sharedDebug/src/shared/InstallTimer.h b/engine/shared/library/sharedDebug/src/shared/InstallTimer.h index 122444e0..5a8d3f42 100755 --- a/engine/shared/library/sharedDebug/src/shared/InstallTimer.h +++ b/engine/shared/library/sharedDebug/src/shared/InstallTimer.h @@ -38,7 +38,6 @@ private: char const * m_description; PerformanceTimer m_performanceTimer; - unsigned long const m_startingNumberOfBytesAllocated; }; // ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp b/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp index 65130ea2..ce7cfaa3 100755 --- a/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp +++ b/engine/shared/library/sharedFoundation/src/linux/SetupSharedFoundation.cpp @@ -51,9 +51,6 @@ void SetupSharedFoundation::install(const Data &data) //@todo there is a lot of stuff in win32 setup not here...like exitchain Profiler::registerDebugFlags(); -#if _DEBUG - MemoryManager::registerDebugFlags(); -#endif//_DEBUG // Setup Linux DebugMonitor support. // @todo fix this dependency: DebugMonitor really should be moved into Foundation the way things currently are. TRF is following the existing win32 setup. diff --git a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp b/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp index 9ab1fce2..8d6fb02e 100755 --- a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp +++ b/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp @@ -5,7 +5,7 @@ // Copyright 2002 Sony Online Entertainment // // ====================================================================== - +/* #include "sharedMemoryManager/FirstSharedMemoryManager.h" #include "sharedMemoryManager/MemoryManager.h" #include "sharedMemoryManager/OsNewDel.h" @@ -88,6 +88,6 @@ void operator delete[](void *pointer, const char *file, int line) throw() if (pointer) MemoryManager::free(pointer, true); } - +*/ // ====================================================================== diff --git a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h b/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h index 46595a62..a1e0a64c 100755 --- a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h +++ b/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h @@ -17,16 +17,19 @@ enum MemoryManagerNotALeak MM_notALeak }; +/* void *operator new(size_t size, MemoryManagerNotALeak); void *operator new(size_t size); void *operator new[](std::size_t size); void *operator new(size_t size, char const *file, int line); void *operator new[](size_t size, char const *file, int line); + void operator delete(void *pointer) throw(); void operator delete[](void *pointer) throw(); void operator delete(void *pointer, char const *file, int line) throw(); void operator delete[](void *pointer, char const *file, int line) throw(); +*/ // ====================================================================== diff --git a/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp b/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp index 9407855b..cbf83b1e 100755 --- a/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp +++ b/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp @@ -1349,7 +1349,7 @@ void *MemoryManager::reallocate(void *userPointer, size_t newSize) if (newSize <= static_cast(oldSize)) { -// DEBUG_REPORT_LOG(ms_logEachAlloc, ("MemoryManager::reallocate() new_requested_size=%d, org ptr=%p, new ptr=%p\n", newSize, userPointer, userPointer)); +// DEBUG_REPORT_LOG(ms_logEachAlloc, ("realloc() new_requested_size=%d, org ptr=%p, new ptr=%p\n", newSize, userPointer, userPointer)); return userPointer; } diff --git a/engine/shared/library/sharedUtility/src/shared/CachedFileManager.cpp b/engine/shared/library/sharedUtility/src/shared/CachedFileManager.cpp index 398ef20e..468c8d00 100755 --- a/engine/shared/library/sharedUtility/src/shared/CachedFileManager.cpp +++ b/engine/shared/library/sharedUtility/src/shared/CachedFileManager.cpp @@ -186,10 +186,6 @@ void CachedFileManager::preloadSomeAssets () { unsigned long const startTime = Clock::timeMs (); -#if PRODUCTION == 0 - unsigned long const bytesBefore = MemoryManager::getCurrentNumberOfBytesAllocated(); -#endif - //-- preloading occurs in one second slices while (ms_filenamesCurrentPos < ms_filenamesLength && Clock::timeMs () - startTime < 1000) { @@ -229,8 +225,6 @@ void CachedFileManager::preloadSomeAssets () #if PRODUCTION == 0 unsigned long const stopTime = Clock::timeMs (); ms_totalTime += stopTime - startTime; - - ms_totalAllocatedBytes += MemoryManager::getCurrentNumberOfBytesAllocated() - bytesBefore; #endif if (donePreloading ()) diff --git a/engine/shared/library/sharedXml/src/shared/core/SetupSharedXml.cpp b/engine/shared/library/sharedXml/src/shared/core/SetupSharedXml.cpp index 750e4a46..dc037cd0 100755 --- a/engine/shared/library/sharedXml/src/shared/core/SetupSharedXml.cpp +++ b/engine/shared/library/sharedXml/src/shared/core/SetupSharedXml.cpp @@ -71,7 +71,7 @@ char *SetupSharedXmlNamespace::xmlDuplicateString(char const *source) void *SetupSharedXmlNamespace::xmlReAllocate(void *memory, size_t byteCount) { - return MemoryManager::reallocate(memory, byteCount); + return realloc(memory, byteCount); } // ====================================================================== diff --git a/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocumentList.cpp b/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocumentList.cpp index 2299aaf5..72932b48 100755 --- a/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocumentList.cpp +++ b/engine/shared/library/sharedXml/src/shared/tree/XmlTreeDocumentList.cpp @@ -116,18 +116,9 @@ XmlTreeDocument const *XmlTreeDocumentList::fetch(CrcString const &filename) delete file; //-- Create an XML DOM tree out of it. -#ifdef _DEBUG - unsigned long const preDomBytesAllocated = MemoryManager::getCurrentNumberOfBytesAllocated(); -#endif - xmlDocPtr const xmlDocument = xmlParseMemory(reinterpret_cast(fileContents), fileSize); FATAL(!xmlDocument, ("xmlParseMemory() returned nullptr when parsing contents of file [%s].", cPathName)); -#ifdef _DEBUG - unsigned long const postDomBytesAllocated = MemoryManager::getCurrentNumberOfBytesAllocated(); - DEBUG_REPORT_LOG(s_logXmlDomTreeSize, ("XmlTreeDocumentList: XML tree file [%s]: XML DOM tree appears to have consumed [%d] bytes.\n", cPathName, static_cast(postDomBytesAllocated - preDomBytesAllocated))); -#endif - // Release initial file contents buffer. delete [] fileContents; diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp index bf736c7c..2784757b 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp @@ -40,12 +40,6 @@ ObjvarBuffer::~ObjvarBuffer() { } -// ---------------------------------------------------------------------- - -/** - * Loads all the object variables for the remembered objectId's - */ - bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std::string &schema, bool usingGoldDatabase) { int rowsFetched; diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h index 61ff386b..f834649b 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h @@ -16,7 +16,7 @@ #include "sharedFoundation/DynamicVariableList.h" #include #include - +#include // ====================================================================== class ObjectTableBuffer; @@ -61,6 +61,9 @@ public: int m_nameId; IndexKey(const NetworkId &objectId, int nameId); + ~IndexKey(){ + m_nameId = 0; + } bool operator==(const IndexKey &rhs) const; bool operator<(const IndexKey &rhs) const; }; @@ -71,6 +74,12 @@ public: std::string m_value; bool m_detached; bool m_inDatabase; + ~ObjvarValue(){ + m_type = 0; + m_detached = 0; + m_inDatabase = 0; + m_value.clear(); + } }; typedef std::map DataType; diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp index ccb9ccad..f81f75ad 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp @@ -139,9 +139,7 @@ SwgSnapshot::SwgSnapshot(DB::ModeQuery::Mode mode, bool useGoldDatabase) : // ---------------------------------------------------------------------- -SwgSnapshot::~SwgSnapshot() -{ -} +SwgSnapshot::~SwgSnapshot(){} // ---------------------------------------------------------------------- diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h index ee36cc39..e2494000 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h +++ b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h @@ -30,7 +30,6 @@ #include "SwgDatabaseServer/Schema.h" #include "SwgDatabaseServer/ScriptBuffer.h" #include "SwgDatabaseServer/WaypointBuffer.h" - namespace DB { class Session; From f9c0a47a39aa0bb7f6d29e61fb47879ac0321337 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 29 Nov 2016 04:25:55 +0000 Subject: [PATCH 02/13] finish removing the SOE memory management --- .../application/Miff/src/CMakeLists.txt | 4 +- .../application/Miff/src/linux/miff.cpp | 2 +- .../application/Miff/src/win32/miff.cpp | 2 +- .../CentralServer/src/CMakeLists.txt | 4 +- .../src/shared/FirstCentralServer.h | 2 +- .../application/ChatServer/src/CMakeLists.txt | 4 +- .../CommoditiesServer/src/CMakeLists.txt | 4 +- .../ConnectionServer/src/CMakeLists.txt | 4 +- .../src/shared/ConnectionServer.cpp | 2 +- .../src/shared/FirstConnectionServer.h | 2 +- .../CustomerServiceServer/src/CMakeLists.txt | 4 +- .../application/LogServer/src/CMakeLists.txt | 4 +- .../application/LoginPing/src/CMakeLists.txt | 4 +- .../LoginServer/src/CMakeLists.txt | 4 +- .../LoginServer/src/shared/FirstLoginServer.h | 2 +- .../LoginServer/src/shared/LoginServer.cpp | 2 +- .../MetricsServer/src/CMakeLists.txt | 4 +- .../PlanetServer/src/CMakeLists.txt | 4 +- .../src/shared/FirstPlanetServer.h | 2 +- .../ServerConsole/src/CMakeLists.txt | 4 +- .../src/CMakeLists.txt | 4 +- .../TaskManager/src/CMakeLists.txt | 4 +- .../TransferServer/src/CMakeLists.txt | 4 +- .../library/serverBase/src/CMakeLists.txt | 2 +- .../library/serverDatabase/src/CMakeLists.txt | 2 +- .../src/shared/FirstServerDatabase.h | 2 +- .../serverDatabase/src/shared/Persister.cpp | 35 +- .../serverDatabase/src/shared/Snapshot.cpp | 5 +- .../src/shared/TaskSaveSnapshot.cpp | 3 + .../library/serverGame/src/CMakeLists.txt | 2 +- .../src/shared/object/TangibleObject.cpp | 4 - .../library/serverKeyShare/src/CMakeLists.txt | 2 +- .../src/shared/FirstServerKeyShare.h | 2 +- .../library/serverMetrics/src/CMakeLists.txt | 2 +- .../serverNetworkMessages/src/CMakeLists.txt | 2 +- .../serverPathfinding/src/CMakeLists.txt | 2 +- .../library/serverScript/src/CMakeLists.txt | 2 +- .../src/shared/FirstServerScript.h | 2 +- .../library/serverUtility/src/CMakeLists.txt | 2 +- .../src/shared/FirstServerUtility.h | 2 +- .../DataTableTool/src/CMakeLists.txt | 4 +- .../TemplateCompiler/src/CMakeLists.txt | 4 +- .../src/CMakeLists.txt | 4 +- engine/shared/library/CMakeLists.txt | 1 - .../sharedCollision/src/CMakeLists.txt | 2 +- .../sharedCommandParser/src/CMakeLists.txt | 2 +- .../sharedCompression/src/CMakeLists.txt | 2 +- .../src/CMakeLists.txt | 2 +- .../core/FirstSharedDatabaseInterface.h | 2 +- .../src_oci/CMakeLists.txt | 2 +- .../library/sharedDebug/src/CMakeLists.txt | 2 +- .../library/sharedFile/src/CMakeLists.txt | 2 +- .../sharedFile/src/shared/FirstSharedFile.h | 2 +- .../sharedFoundation/src/CMakeLists.txt | 2 +- .../src/linux/ConfigSharedFoundation.cpp | 8 +- .../src/linux/FirstPlatform.h | 2 +- .../src/shared/FirstSharedFoundation.h | 2 +- .../src/win32/ConfigSharedFoundation.cpp | 6 +- .../library/sharedFractal/src/CMakeLists.txt | 2 +- .../src/shared/FirstSharedFractal.h | 2 +- .../library/sharedGame/src/CMakeLists.txt | 2 +- .../src/shared/core/FirstSharedGame.h | 2 +- .../library/sharedImage/src/CMakeLists.txt | 2 +- .../library/sharedIoWin/src/CMakeLists.txt | 2 +- .../library/sharedLog/src/CMakeLists.txt | 2 +- .../library/sharedMath/src/CMakeLists.txt | 2 +- .../sharedMathArchive/src/CMakeLists.txt | 2 +- .../sharedMemoryManager/CMakeLists.txt | 8 - .../private/sharedMemoryManager/OsMemory.h | 7 - .../FirstSharedMemoryManager.h | 1 - .../sharedMemoryManager/MemoryManager.h | 1 - .../public/sharedMemoryManager/OsNewDel.h | 7 - .../sharedMemoryManager/src/CMakeLists.txt | 40 - .../src/linux/OsMemory.cpp | 40 - .../sharedMemoryManager/src/linux/OsMemory.h | 29 - .../src/linux/OsNewDel.cpp | 93 - .../sharedMemoryManager/src/linux/OsNewDel.h | 37 - .../src/shared/FirstSharedMemoryManager.cpp | 8 - .../src/shared/FirstSharedMemoryManager.h | 19 - .../src/shared/MemoryManager.cpp | 2180 ----------------- .../src/shared/MemoryManager.h | 84 - .../src/win32/OsMemory.cpp | 56 - .../sharedMemoryManager/src/win32/OsMemory.h | 29 - .../src/win32/OsNewDel.cpp | 211 -- .../sharedMemoryManager/src/win32/OsNewDel.h | 52 - .../sharedMessageDispatch/src/CMakeLists.txt | 2 +- .../library/sharedNetwork/src/CMakeLists.txt | 2 +- .../src/shared/FirstSharedNetwork.h | 2 +- .../sharedNetworkMessages/src/CMakeLists.txt | 2 +- .../library/sharedObject/src/CMakeLists.txt | 2 +- .../sharedPathfinding/src/CMakeLists.txt | 2 +- .../library/sharedRandom/src/CMakeLists.txt | 2 +- .../library/sharedRegex/src/CMakeLists.txt | 2 +- .../src/CMakeLists.txt | 2 +- .../sharedSkillSystem/src/CMakeLists.txt | 2 +- .../sharedSynchronization/src/CMakeLists.txt | 2 +- .../library/sharedTemplate/src/CMakeLists.txt | 2 +- .../src/CMakeLists.txt | 2 +- .../library/sharedTerrain/src/CMakeLists.txt | 2 +- .../library/sharedThread/src/CMakeLists.txt | 2 +- .../library/sharedUtility/src/CMakeLists.txt | 2 +- .../library/sharedXml/src/CMakeLists.txt | 2 +- .../SwgDatabaseServer/src/CMakeLists.txt | 4 +- .../src/shared/buffers/ObjvarBuffer.cpp | 23 +- .../src/shared/buffers/ObjvarBuffer.h | 21 +- .../src/shared/core/FirstSwgDatabaseServer.h | 2 +- .../SwgGameServer/src/CMakeLists.txt | 4 +- .../src/shared/core/FirstSwgGameServer.h | 2 +- .../src/CMakeLists.txt | 2 +- .../core/FirstSwgServerNetworkMessages.h | 2 +- .../src/CMakeLists.txt | 2 +- .../core/FirstSwgSharedNetworkMessages.h | 2 +- .../swgSharedUtility/src/CMakeLists.txt | 2 +- 113 files changed, 163 insertions(+), 3057 deletions(-) delete mode 100644 engine/shared/library/sharedMemoryManager/CMakeLists.txt delete mode 100755 engine/shared/library/sharedMemoryManager/include/private/sharedMemoryManager/OsMemory.h delete mode 100755 engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/FirstSharedMemoryManager.h delete mode 100755 engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/MemoryManager.h delete mode 100755 engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/OsNewDel.h delete mode 100644 engine/shared/library/sharedMemoryManager/src/CMakeLists.txt delete mode 100755 engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp delete mode 100755 engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h diff --git a/engine/client/application/Miff/src/CMakeLists.txt b/engine/client/application/Miff/src/CMakeLists.txt index 847ce762..116f41af 100644 --- a/engine/client/application/Miff/src/CMakeLists.txt +++ b/engine/client/application/Miff/src/CMakeLists.txt @@ -27,7 +27,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public ) @@ -68,7 +68,7 @@ target_link_libraries(Miff sharedFile sharedFoundation sharedLog - sharedMemoryManager + sharedMessageDispatch sharedThread fileInterface diff --git a/engine/client/application/Miff/src/linux/miff.cpp b/engine/client/application/Miff/src/linux/miff.cpp index 8f62be65..d1f18bfc 100755 --- a/engine/client/application/Miff/src/linux/miff.cpp +++ b/engine/client/application/Miff/src/linux/miff.cpp @@ -41,7 +41,7 @@ #include "sharedFoundation/Crc.h" #include "sharedFoundation/Os.h" #include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedMemoryManager/MemoryManager.h" + #include "sharedThread/SetupSharedThread.h" #include "InputFileHandler.h" diff --git a/engine/client/application/Miff/src/win32/miff.cpp b/engine/client/application/Miff/src/win32/miff.cpp index 89535216..1963c21c 100644 --- a/engine/client/application/Miff/src/win32/miff.cpp +++ b/engine/client/application/Miff/src/win32/miff.cpp @@ -41,7 +41,7 @@ #include "sharedFoundation/Crc.h" #include "sharedFoundation/Os.h" #include "sharedFoundation/SetupSharedFoundation.h" -#include "sharedMemoryManager/MemoryManager.h" + #include "sharedThread/SetupSharedThread.h" #include "InputFileHandler.h" diff --git a/engine/server/application/CentralServer/src/CMakeLists.txt b/engine/server/application/CentralServer/src/CMakeLists.txt index 1bfd4dd6..4354e1ad 100755 --- a/engine/server/application/CentralServer/src/CMakeLists.txt +++ b/engine/server/application/CentralServer/src/CMakeLists.txt @@ -132,7 +132,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -171,7 +171,7 @@ target_link_libraries(CentralServer sharedGame sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/CentralServer/src/shared/FirstCentralServer.h b/engine/server/application/CentralServer/src/shared/FirstCentralServer.h index b9fd589c..527ee252 100755 --- a/engine/server/application/CentralServer/src/shared/FirstCentralServer.h +++ b/engine/server/application/CentralServer/src/shared/FirstCentralServer.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "sharedFoundation/NetworkIdArchive.h" #include "CentralServer.h" diff --git a/engine/server/application/ChatServer/src/CMakeLists.txt b/engine/server/application/ChatServer/src/CMakeLists.txt index 669d7e10..c6400926 100644 --- a/engine/server/application/ChatServer/src/CMakeLists.txt +++ b/engine/server/application/ChatServer/src/CMakeLists.txt @@ -50,7 +50,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -83,7 +83,7 @@ target_link_libraries(ChatServer sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/CommoditiesServer/src/CMakeLists.txt b/engine/server/application/CommoditiesServer/src/CMakeLists.txt index 1401d620..8ba55ff9 100644 --- a/engine/server/application/CommoditiesServer/src/CMakeLists.txt +++ b/engine/server/application/CommoditiesServer/src/CMakeLists.txt @@ -44,7 +44,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -75,7 +75,7 @@ target_link_libraries(CommoditiesServer sharedFile sharedFoundation sharedGame - sharedMemoryManager + sharedLog sharedMessageDispatch sharedNetwork diff --git a/engine/server/application/ConnectionServer/src/CMakeLists.txt b/engine/server/application/ConnectionServer/src/CMakeLists.txt index 4e6ebe0d..6737fd50 100644 --- a/engine/server/application/ConnectionServer/src/CMakeLists.txt +++ b/engine/server/application/ConnectionServer/src/CMakeLists.txt @@ -47,7 +47,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -83,7 +83,7 @@ target_link_libraries(ConnectionServer sharedGame sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp index 0ca253d3..ef838c04 100755 --- a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp @@ -45,7 +45,7 @@ #include "sharedLog/Log.h" #include "sharedLog/LogManager.h" #include "sharedLog/SetupSharedLog.h" -#include "sharedMemoryManager/MemoryManager.h" + #include "sharedNetwork/NetworkSetupData.h" #include "sharedNetwork/Service.h" #include "sharedNetwork/UdpSock.h" diff --git a/engine/server/application/ConnectionServer/src/shared/FirstConnectionServer.h b/engine/server/application/ConnectionServer/src/shared/FirstConnectionServer.h index 6fd3b73b..d8dbf562 100755 --- a/engine/server/application/ConnectionServer/src/shared/FirstConnectionServer.h +++ b/engine/server/application/ConnectionServer/src/shared/FirstConnectionServer.h @@ -11,7 +11,7 @@ // ====================================================================== #include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "sharedDebug/FirstSharedDebug.h" #include "ConnectionServer.h" #include "sharedFoundation/NetworkIdArchive.h" diff --git a/engine/server/application/CustomerServiceServer/src/CMakeLists.txt b/engine/server/application/CustomerServiceServer/src/CMakeLists.txt index be0080a6..4506878c 100644 --- a/engine/server/application/CustomerServiceServer/src/CMakeLists.txt +++ b/engine/server/application/CustomerServiceServer/src/CMakeLists.txt @@ -40,7 +40,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -69,7 +69,7 @@ target_link_libraries(CustomerServiceServer sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/LogServer/src/CMakeLists.txt b/engine/server/application/LogServer/src/CMakeLists.txt index 93a25b7d..39add001 100644 --- a/engine/server/application/LogServer/src/CMakeLists.txt +++ b/engine/server/application/LogServer/src/CMakeLists.txt @@ -35,7 +35,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -61,7 +61,7 @@ target_link_libraries(LogServer sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/LoginPing/src/CMakeLists.txt b/engine/server/application/LoginPing/src/CMakeLists.txt index f2db328b..1997b00f 100644 --- a/engine/server/application/LoginPing/src/CMakeLists.txt +++ b/engine/server/application/LoginPing/src/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -45,7 +45,7 @@ target_link_libraries(LoginPing sharedDebug sharedFile sharedFoundation - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/LoginServer/src/CMakeLists.txt b/engine/server/application/LoginServer/src/CMakeLists.txt index 80a0989a..7f53d812 100644 --- a/engine/server/application/LoginServer/src/CMakeLists.txt +++ b/engine/server/application/LoginServer/src/CMakeLists.txt @@ -90,7 +90,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -129,7 +129,7 @@ target_link_libraries(LoginServer sharedGame sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/LoginServer/src/shared/FirstLoginServer.h b/engine/server/application/LoginServer/src/shared/FirstLoginServer.h index 76cd4a1e..728af28c 100755 --- a/engine/server/application/LoginServer/src/shared/FirstLoginServer.h +++ b/engine/server/application/LoginServer/src/shared/FirstLoginServer.h @@ -15,7 +15,7 @@ #include "Archive/ByteStream.h" #include "serverUtility/ServerConnection.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "LoginServer.h" #include "sharedNetworkMessages/GameNetworkMessage.h" // ====================================================================== diff --git a/engine/server/application/LoginServer/src/shared/LoginServer.cpp b/engine/server/application/LoginServer/src/shared/LoginServer.cpp index 17e7e760..ee51db59 100755 --- a/engine/server/application/LoginServer/src/shared/LoginServer.cpp +++ b/engine/server/application/LoginServer/src/shared/LoginServer.cpp @@ -60,7 +60,7 @@ #include "sharedGame/PlatformFeatureBits.h" #include "sharedLog/Log.h" #include "sharedLog/SetupSharedLog.h" -#include "sharedMemoryManager/MemoryManager.h" + #include "sharedNetwork/Address.h" #include "sharedNetwork/NetworkSetupData.h" #include "sharedNetworkMessages/ClientCentralMessages.h" diff --git a/engine/server/application/MetricsServer/src/CMakeLists.txt b/engine/server/application/MetricsServer/src/CMakeLists.txt index 1133349b..dbbe71c9 100644 --- a/engine/server/application/MetricsServer/src/CMakeLists.txt +++ b/engine/server/application/MetricsServer/src/CMakeLists.txt @@ -29,7 +29,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -54,7 +54,7 @@ target_link_libraries(MetricsServer sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/PlanetServer/src/CMakeLists.txt b/engine/server/application/PlanetServer/src/CMakeLists.txt index 0167c811..e0eefd7a 100644 --- a/engine/server/application/PlanetServer/src/CMakeLists.txt +++ b/engine/server/application/PlanetServer/src/CMakeLists.txt @@ -53,7 +53,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -86,7 +86,7 @@ target_link_libraries(PlanetServer sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/PlanetServer/src/shared/FirstPlanetServer.h b/engine/server/application/PlanetServer/src/shared/FirstPlanetServer.h index d4d14d3b..52862f46 100755 --- a/engine/server/application/PlanetServer/src/shared/FirstPlanetServer.h +++ b/engine/server/application/PlanetServer/src/shared/FirstPlanetServer.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "sharedFoundation/NetworkIdArchive.h" diff --git a/engine/server/application/ServerConsole/src/CMakeLists.txt b/engine/server/application/ServerConsole/src/CMakeLists.txt index 6bf5f9d6..0090a17d 100644 --- a/engine/server/application/ServerConsole/src/CMakeLists.txt +++ b/engine/server/application/ServerConsole/src/CMakeLists.txt @@ -27,7 +27,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -45,7 +45,7 @@ target_link_libraries(ServerConsole sharedDebug sharedFile sharedFoundation - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/StationPlayersCollector/src/CMakeLists.txt b/engine/server/application/StationPlayersCollector/src/CMakeLists.txt index 20912987..7759b2e9 100644 --- a/engine/server/application/StationPlayersCollector/src/CMakeLists.txt +++ b/engine/server/application/StationPlayersCollector/src/CMakeLists.txt @@ -31,7 +31,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -58,7 +58,7 @@ target_link_libraries(StationPlayersCollector sharedFile sharedFoundation sharedLog - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/TaskManager/src/CMakeLists.txt b/engine/server/application/TaskManager/src/CMakeLists.txt index 2a744604..5d3fa1e8 100644 --- a/engine/server/application/TaskManager/src/CMakeLists.txt +++ b/engine/server/application/TaskManager/src/CMakeLists.txt @@ -61,7 +61,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -86,7 +86,7 @@ target_link_libraries(TaskManager sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/application/TransferServer/src/CMakeLists.txt b/engine/server/application/TransferServer/src/CMakeLists.txt index 024c5369..10b4d4ce 100644 --- a/engine/server/application/TransferServer/src/CMakeLists.txt +++ b/engine/server/application/TransferServer/src/CMakeLists.txt @@ -35,7 +35,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -61,7 +61,7 @@ target_link_libraries(TransferServer sharedFoundation sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/engine/server/library/serverBase/src/CMakeLists.txt b/engine/server/library/serverBase/src/CMakeLists.txt index 0b8c6bba..9a0ff449 100644 --- a/engine/server/library/serverBase/src/CMakeLists.txt +++ b/engine/server/library/serverBase/src/CMakeLists.txt @@ -16,7 +16,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverDatabase/src/CMakeLists.txt b/engine/server/library/serverDatabase/src/CMakeLists.txt index 0dbe652c..9d407974 100644 --- a/engine/server/library/serverDatabase/src/CMakeLists.txt +++ b/engine/server/library/serverDatabase/src/CMakeLists.txt @@ -151,7 +151,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverDatabase/src/shared/FirstServerDatabase.h b/engine/server/library/serverDatabase/src/shared/FirstServerDatabase.h index 8f490a68..5aec339c 100755 --- a/engine/server/library/serverDatabase/src/shared/FirstServerDatabase.h +++ b/engine/server/library/serverDatabase/src/shared/FirstServerDatabase.h @@ -2,6 +2,6 @@ #define INCLUDED_FirstServerDatabase_H #include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #endif diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 218e47f2..30f951c6 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -174,15 +174,44 @@ Persister::~Persister() { DEBUG_FATAL(taskQueue,("Call shutdown() before deleting Persister.\n")); - ServerSnapshotMap::iterator i; - for (i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) + for (auto i = m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) { delete i->second; - for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) + i->second = nullptr; + } + + for (auto i = m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) { delete i->second; + i->second = nullptr; + } + + for (auto i = m_newCharacterSnapshots.begin(); i!=m_newCharacterSnapshots.end(); ++i) { + delete i->second; + i->second = nullptr; + } + + for (auto i = m_objectSnapshotMap.begin(); i!=m_objectSnapshotMap.end(); ++i) { + delete i->second; + i->second = nullptr; + } + + for (auto i = m_savingSnapshots.begin(); i!=m_savingSnapshots.end(); ++i) { + delete *i; + *i = nullptr; + } + + for (auto i = m_savingCharacterSnapshots.begin(); i!=m_savingCharacterSnapshots.end(); ++i) { + delete *i; + *i = nullptr; + } m_currentSnapshots.clear(); m_newObjectSnapshots.clear(); m_objectSnapshotMap.clear(); + + delete m_messageSnapshot; + delete m_commoditiesSnapshot; + delete m_arbitraryGameDataSnapshot; + m_messageSnapshot = nullptr; m_commoditiesSnapshot = nullptr; m_arbitraryGameDataSnapshot = nullptr; diff --git a/engine/server/library/serverDatabase/src/shared/Snapshot.cpp b/engine/server/library/serverDatabase/src/shared/Snapshot.cpp index 768d8f99..17209379 100755 --- a/engine/server/library/serverDatabase/src/shared/Snapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/Snapshot.cpp @@ -50,8 +50,11 @@ Snapshot::~Snapshot() *j = nullptr; } + m_locatorList.clear(); + m_customStepList.clear(); + ++ms_deletionCount; - LOG("Snapshot",("Deleted snapshot. %i outstanding, %i created, %i deleted", ms_creationCount-ms_deletionCount,ms_creationCount,ms_deletionCount)); + LOG("Snapshot",("Deleted snapshot. %i outstanding, %i created, %i deleted", ms_creationCount-ms_deletionCount,ms_creationCount,ms_deletionCount)); } // ---------------------------------------------------------------------- diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp index 2222b250..982de1ef 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp @@ -30,6 +30,9 @@ void TaskSaveSnapshot::onComplete() { m_snapshot->saveCompleted(); Persister::getInstance().saveCompleted(m_snapshot); + + delete m_snapshot; + m_snapshot = nullptr; } // ====================================================================== diff --git a/engine/server/library/serverGame/src/CMakeLists.txt b/engine/server/library/serverGame/src/CMakeLists.txt index 98fb2c19..ab347036 100644 --- a/engine/server/library/serverGame/src/CMakeLists.txt +++ b/engine/server/library/serverGame/src/CMakeLists.txt @@ -732,7 +732,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp b/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp index 4f3c1ebf..13768966 100755 --- a/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/TangibleObject.cpp @@ -566,7 +566,6 @@ TangibleObject::~TangibleObject() const int maxStackDepth = 64; const int callStackSize = callStackOffset + maxStackDepth; uint32 callStack[callStackOffset + maxStackDepth]; - DebugHelp::getCallStack(callStack, callStackOffset + maxStackDepth); // look up the caller's file and line if (callStack[callStackOffset]) @@ -579,10 +578,7 @@ TangibleObject::~TangibleObject() { if (callStack[i]) { - if (DebugHelp::lookupAddress(callStack[i], lib, file, sizeof(file), line)) REPORT_LOG(true, ("\t%s(%d) : caller %d\n", file, line, i-callStackOffset)); - else - REPORT_LOG(true, ("\tunknown(0x%08X) : caller %d\n", static_cast(callStack[i]), i-callStackOffset)); } } } diff --git a/engine/server/library/serverKeyShare/src/CMakeLists.txt b/engine/server/library/serverKeyShare/src/CMakeLists.txt index f5867b21..3ea852ab 100644 --- a/engine/server/library/serverKeyShare/src/CMakeLists.txt +++ b/engine/server/library/serverKeyShare/src/CMakeLists.txt @@ -20,7 +20,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/crypto/include diff --git a/engine/server/library/serverKeyShare/src/shared/FirstServerKeyShare.h b/engine/server/library/serverKeyShare/src/shared/FirstServerKeyShare.h index 5875846a..fc95fc90 100755 --- a/engine/server/library/serverKeyShare/src/shared/FirstServerKeyShare.h +++ b/engine/server/library/serverKeyShare/src/shared/FirstServerKeyShare.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "serverKeyShare/KeyServer.h" #include "sharedRandom/RandomGenerator.h" diff --git a/engine/server/library/serverMetrics/src/CMakeLists.txt b/engine/server/library/serverMetrics/src/CMakeLists.txt index 84f5929b..b414eead 100644 --- a/engine/server/library/serverMetrics/src/CMakeLists.txt +++ b/engine/server/library/serverMetrics/src/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverNetworkMessages/src/CMakeLists.txt b/engine/server/library/serverNetworkMessages/src/CMakeLists.txt index edb6e914..a0ec77cf 100644 --- a/engine/server/library/serverNetworkMessages/src/CMakeLists.txt +++ b/engine/server/library/serverNetworkMessages/src/CMakeLists.txt @@ -492,7 +492,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverPathfinding/src/CMakeLists.txt b/engine/server/library/serverPathfinding/src/CMakeLists.txt index 14e03fbb..d1bb2dca 100644 --- a/engine/server/library/serverPathfinding/src/CMakeLists.txt +++ b/engine/server/library/serverPathfinding/src/CMakeLists.txt @@ -43,7 +43,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public diff --git a/engine/server/library/serverScript/src/CMakeLists.txt b/engine/server/library/serverScript/src/CMakeLists.txt index 7190ea0e..d1c75434 100644 --- a/engine/server/library/serverScript/src/CMakeLists.txt +++ b/engine/server/library/serverScript/src/CMakeLists.txt @@ -112,7 +112,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverScript/src/shared/FirstServerScript.h b/engine/server/library/serverScript/src/shared/FirstServerScript.h index 5735b6b2..28c07e87 100755 --- a/engine/server/library/serverScript/src/shared/FirstServerScript.h +++ b/engine/server/library/serverScript/src/shared/FirstServerScript.h @@ -2,7 +2,7 @@ #define INCLUDED_FirstServerScript_H #include "sharedFoundation/FirstSharedFoundation.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "StringId.h" #include diff --git a/engine/server/library/serverUtility/src/CMakeLists.txt b/engine/server/library/serverUtility/src/CMakeLists.txt index b522f2c1..5b7aa219 100644 --- a/engine/server/library/serverUtility/src/CMakeLists.txt +++ b/engine/server/library/serverUtility/src/CMakeLists.txt @@ -49,7 +49,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/server/library/serverUtility/src/shared/FirstServerUtility.h b/engine/server/library/serverUtility/src/shared/FirstServerUtility.h index ff451891..705de846 100755 --- a/engine/server/library/serverUtility/src/shared/FirstServerUtility.h +++ b/engine/server/library/serverUtility/src/shared/FirstServerUtility.h @@ -3,6 +3,6 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #endif diff --git a/engine/shared/application/DataTableTool/src/CMakeLists.txt b/engine/shared/application/DataTableTool/src/CMakeLists.txt index c4ac003c..cdc586a4 100644 --- a/engine/shared/application/DataTableTool/src/CMakeLists.txt +++ b/engine/shared/application/DataTableTool/src/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedIoWin/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public @@ -40,7 +40,7 @@ target_link_libraries(DataTableTool sharedFoundation sharedIoWin sharedLog - sharedMemoryManager + sharedMessageDispatch sharedObject sharedRandom diff --git a/engine/shared/application/TemplateCompiler/src/CMakeLists.txt b/engine/shared/application/TemplateCompiler/src/CMakeLists.txt index 6c1a91c8..c1693cc5 100644 --- a/engine/shared/application/TemplateCompiler/src/CMakeLists.txt +++ b/engine/shared/application/TemplateCompiler/src/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public @@ -49,7 +49,7 @@ target_link_libraries(TemplateCompiler sharedFile sharedFoundation sharedLog - sharedMemoryManager + sharedMessageDispatch sharedObject sharedRandom diff --git a/engine/shared/application/TemplateDefinitionCompiler/src/CMakeLists.txt b/engine/shared/application/TemplateDefinitionCompiler/src/CMakeLists.txt index 8434c74c..f9b95c9f 100644 --- a/engine/shared/application/TemplateDefinitionCompiler/src/CMakeLists.txt +++ b/engine/shared/application/TemplateDefinitionCompiler/src/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public @@ -49,7 +49,7 @@ target_link_libraries(TemplateDefinitionCompiler sharedFile sharedFoundation sharedLog - sharedMemoryManager + sharedMessageDispatch sharedObject sharedRandom diff --git a/engine/shared/library/CMakeLists.txt b/engine/shared/library/CMakeLists.txt index 8681a535..a03d3330 100644 --- a/engine/shared/library/CMakeLists.txt +++ b/engine/shared/library/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(sharedIoWin) add_subdirectory(sharedLog) add_subdirectory(sharedMath) add_subdirectory(sharedMathArchive) -add_subdirectory(sharedMemoryManager) add_subdirectory(sharedMessageDispatch) add_subdirectory(sharedNetwork) add_subdirectory(sharedNetworkMessages) diff --git a/engine/shared/library/sharedCollision/src/CMakeLists.txt b/engine/shared/library/sharedCollision/src/CMakeLists.txt index 259cd944..56a160e5 100644 --- a/engine/shared/library/sharedCollision/src/CMakeLists.txt +++ b/engine/shared/library/sharedCollision/src/CMakeLists.txt @@ -140,7 +140,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTerrain/include/public diff --git a/engine/shared/library/sharedCommandParser/src/CMakeLists.txt b/engine/shared/library/sharedCommandParser/src/CMakeLists.txt index d36b0fdd..4bf57f53 100644 --- a/engine/shared/library/sharedCommandParser/src/CMakeLists.txt +++ b/engine/shared/library/sharedCommandParser/src/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ) diff --git a/engine/shared/library/sharedCompression/src/CMakeLists.txt b/engine/shared/library/sharedCompression/src/CMakeLists.txt index fbb8e487..04497de7 100644 --- a/engine/shared/library/sharedCompression/src/CMakeLists.txt +++ b/engine/shared/library/sharedCompression/src/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${ZLIB_INCLUDE_DIR} ) diff --git a/engine/shared/library/sharedDatabaseInterface/src/CMakeLists.txt b/engine/shared/library/sharedDatabaseInterface/src/CMakeLists.txt index fbd810d0..84c3cd98 100644 --- a/engine/shared/library/sharedDatabaseInterface/src/CMakeLists.txt +++ b/engine/shared/library/sharedDatabaseInterface/src/CMakeLists.txt @@ -80,7 +80,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include diff --git a/engine/shared/library/sharedDatabaseInterface/src/shared/core/FirstSharedDatabaseInterface.h b/engine/shared/library/sharedDatabaseInterface/src/shared/core/FirstSharedDatabaseInterface.h index dacf606a..5059bb0e 100755 --- a/engine/shared/library/sharedDatabaseInterface/src/shared/core/FirstSharedDatabaseInterface.h +++ b/engine/shared/library/sharedDatabaseInterface/src/shared/core/FirstSharedDatabaseInterface.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + // ====================================================================== diff --git a/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt b/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt index e656be4c..e7094699 100644 --- a/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt +++ b/engine/shared/library/sharedDatabaseInterface/src_oci/CMakeLists.txt @@ -15,7 +15,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ${ORACLE_INCLUDE_DIR} diff --git a/engine/shared/library/sharedDebug/src/CMakeLists.txt b/engine/shared/library/sharedDebug/src/CMakeLists.txt index 13bce2b7..42204df2 100644 --- a/engine/shared/library/sharedDebug/src/CMakeLists.txt +++ b/engine/shared/library/sharedDebug/src/CMakeLists.txt @@ -64,7 +64,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/shared ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/vtune ) diff --git a/engine/shared/library/sharedFile/src/CMakeLists.txt b/engine/shared/library/sharedFile/src/CMakeLists.txt index 722d956c..a1c0ce38 100644 --- a/engine/shared/library/sharedFile/src/CMakeLists.txt +++ b/engine/shared/library/sharedFile/src/CMakeLists.txt @@ -53,7 +53,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public diff --git a/engine/shared/library/sharedFile/src/shared/FirstSharedFile.h b/engine/shared/library/sharedFile/src/shared/FirstSharedFile.h index 7add7f5a..d606f3fe 100755 --- a/engine/shared/library/sharedFile/src/shared/FirstSharedFile.h +++ b/engine/shared/library/sharedFile/src/shared/FirstSharedFile.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + // ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/CMakeLists.txt b/engine/shared/library/sharedFoundation/src/CMakeLists.txt index 244b7ec0..b8d44277 100644 --- a/engine/shared/library/sharedFoundation/src/CMakeLists.txt +++ b/engine/shared/library/sharedFoundation/src/CMakeLists.txt @@ -152,7 +152,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include diff --git a/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp b/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp index 79aab435..1eac42a6 100755 --- a/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp +++ b/engine/shared/library/sharedFoundation/src/linux/ConfigSharedFoundation.cpp @@ -91,11 +91,11 @@ void ConfigSharedFoundation::install (const Defaults &defaults) KEY_BOOL(useRemoteDebug, false); KEY_INT(defaultRemoteDebugPort, 4445); - KEY_BOOL(profilerExpandAllBranches, true); - KEY_BOOL(memoryManagerReportAllocations, true); - KEY_BOOL(memoryManagerReportOnOutOfMemory, true); + KEY_BOOL(profilerExpandAllBranches, false); + KEY_BOOL(memoryManagerReportAllocations, false); + KEY_BOOL(memoryManagerReportOnOutOfMemory, false); - KEY_BOOL(useMemoryBlockManager, true); + KEY_BOOL(useMemoryBlockManager, false); KEY_BOOL(memoryBlockManagerDebugDumpOnRemove, false); KEY_INT(fatalCallStackDepth, c_defaultFatalCallStackDepth); diff --git a/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h b/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h index 7d2ac3bc..752bb84f 100755 --- a/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h +++ b/engine/shared/library/sharedFoundation/src/linux/FirstPlatform.h @@ -32,7 +32,7 @@ #include #include "sharedFoundation/PlatformGlue.h" -#include "sharedMemoryManager/MemoryManager.h" + // ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/shared/FirstSharedFoundation.h b/engine/shared/library/sharedFoundation/src/shared/FirstSharedFoundation.h index 60793e0d..6117ad63 100755 --- a/engine/shared/library/sharedFoundation/src/shared/FirstSharedFoundation.h +++ b/engine/shared/library/sharedFoundation/src/shared/FirstSharedFoundation.h @@ -34,7 +34,7 @@ #include "sharedFoundationTypes/FoundationTypes.h" #include "sharedFoundation/FirstPlatform.h" -#include "sharedMemoryManager/MemoryManager.h" + // ====================================================================== diff --git a/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp b/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp index 9498c256..183191bf 100755 --- a/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp +++ b/engine/shared/library/sharedFoundation/src/win32/ConfigSharedFoundation.cpp @@ -103,9 +103,9 @@ void ConfigSharedFoundation::install (const Defaults &defaults) KEY_INT(defaultRemoteDebugPort, 4445); KEY_BOOL(profilerExpandAllBranches, false); - KEY_BOOL(memoryManagerReportAllocations, true); - KEY_BOOL(memoryManagerReportOnOutOfMemory, true); - KEY_BOOL(useMemoryBlockManager, true); + KEY_BOOL(memoryManagerReportAllocations, false); + KEY_BOOL(memoryManagerReportOnOutOfMemory, false); + KEY_BOOL(useMemoryBlockManager, false); KEY_BOOL(memoryBlockManagerDebugDumpOnRemove, false); KEY_INT(fatalCallStackDepth, c_defaultFatalCallStackDepth); diff --git a/engine/shared/library/sharedFractal/src/CMakeLists.txt b/engine/shared/library/sharedFractal/src/CMakeLists.txt index a535f013..e894250d 100644 --- a/engine/shared/library/sharedFractal/src/CMakeLists.txt +++ b/engine/shared/library/sharedFractal/src/CMakeLists.txt @@ -23,7 +23,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ) diff --git a/engine/shared/library/sharedFractal/src/shared/FirstSharedFractal.h b/engine/shared/library/sharedFractal/src/shared/FirstSharedFractal.h index 9775607e..1b758096 100755 --- a/engine/shared/library/sharedFractal/src/shared/FirstSharedFractal.h +++ b/engine/shared/library/sharedFractal/src/shared/FirstSharedFractal.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + // ====================================================================== diff --git a/engine/shared/library/sharedGame/src/CMakeLists.txt b/engine/shared/library/sharedGame/src/CMakeLists.txt index 67f45c4e..f6cc008a 100644 --- a/engine/shared/library/sharedGame/src/CMakeLists.txt +++ b/engine/shared/library/sharedGame/src/CMakeLists.txt @@ -317,7 +317,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public diff --git a/engine/shared/library/sharedGame/src/shared/core/FirstSharedGame.h b/engine/shared/library/sharedGame/src/shared/core/FirstSharedGame.h index 2047f92b..787cc552 100755 --- a/engine/shared/library/sharedGame/src/shared/core/FirstSharedGame.h +++ b/engine/shared/library/sharedGame/src/shared/core/FirstSharedGame.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "StringId.h" // ====================================================================== diff --git a/engine/shared/library/sharedImage/src/CMakeLists.txt b/engine/shared/library/sharedImage/src/CMakeLists.txt index deb90a57..29f2c5a2 100644 --- a/engine/shared/library/sharedImage/src/CMakeLists.txt +++ b/engine/shared/library/sharedImage/src/CMakeLists.txt @@ -33,7 +33,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public ) diff --git a/engine/shared/library/sharedIoWin/src/CMakeLists.txt b/engine/shared/library/sharedIoWin/src/CMakeLists.txt index 44d4e30b..7289647a 100644 --- a/engine/shared/library/sharedIoWin/src/CMakeLists.txt +++ b/engine/shared/library/sharedIoWin/src/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ) add_library(sharedIoWin STATIC diff --git a/engine/shared/library/sharedLog/src/CMakeLists.txt b/engine/shared/library/sharedLog/src/CMakeLists.txt index 4c7e45b6..6f3f5f69 100644 --- a/engine/shared/library/sharedLog/src/CMakeLists.txt +++ b/engine/shared/library/sharedLog/src/CMakeLists.txt @@ -41,7 +41,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public diff --git a/engine/shared/library/sharedMath/src/CMakeLists.txt b/engine/shared/library/sharedMath/src/CMakeLists.txt index e58839aa..3351e43c 100644 --- a/engine/shared/library/sharedMath/src/CMakeLists.txt +++ b/engine/shared/library/sharedMath/src/CMakeLists.txt @@ -121,7 +121,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public diff --git a/engine/shared/library/sharedMathArchive/src/CMakeLists.txt b/engine/shared/library/sharedMathArchive/src/CMakeLists.txt index 04d07f7e..d0eb2a11 100644 --- a/engine/shared/library/sharedMathArchive/src/CMakeLists.txt +++ b/engine/shared/library/sharedMathArchive/src/CMakeLists.txt @@ -18,7 +18,7 @@ include_directories( #${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public #${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public #${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - #${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + # ) add_library(sharedMathArchive STATIC ${EXCLUDE_PROJECT} diff --git a/engine/shared/library/sharedMemoryManager/CMakeLists.txt b/engine/shared/library/sharedMemoryManager/CMakeLists.txt deleted file mode 100644 index 3968ec03..00000000 --- a/engine/shared/library/sharedMemoryManager/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(sharedMemoryManager) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/private) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/public) - -add_subdirectory(src) diff --git a/engine/shared/library/sharedMemoryManager/include/private/sharedMemoryManager/OsMemory.h b/engine/shared/library/sharedMemoryManager/include/private/sharedMemoryManager/OsMemory.h deleted file mode 100755 index eee3c819..00000000 --- a/engine/shared/library/sharedMemoryManager/include/private/sharedMemoryManager/OsMemory.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(PLATFORM_WIN32) -#include "../../src/win32/OsMemory.h" -#elif defined(PLATFORM_LINUX) -#include "../../src/linux/OsMemory.h" -#else -#error unsupported platform -#endif diff --git a/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/FirstSharedMemoryManager.h b/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/FirstSharedMemoryManager.h deleted file mode 100755 index 44494b87..00000000 --- a/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/FirstSharedMemoryManager.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/FirstSharedMemoryManager.h" diff --git a/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/MemoryManager.h b/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/MemoryManager.h deleted file mode 100755 index d99f899b..00000000 --- a/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/MemoryManager.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../src/shared/MemoryManager.h" diff --git a/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/OsNewDel.h b/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/OsNewDel.h deleted file mode 100755 index 6ddbc618..00000000 --- a/engine/shared/library/sharedMemoryManager/include/public/sharedMemoryManager/OsNewDel.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(PLATFORM_WIN32) -#include "../../src/win32/OsNewDel.h" -#elif defined(PLATFORM_LINUX) -#include "../../src/linux/OsNewDel.h" -#else -#error unsupported platform -#endif diff --git a/engine/shared/library/sharedMemoryManager/src/CMakeLists.txt b/engine/shared/library/sharedMemoryManager/src/CMakeLists.txt deleted file mode 100644 index c475b785..00000000 --- a/engine/shared/library/sharedMemoryManager/src/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ - -set(SHARED_SOURCES - shared/FirstSharedMemoryManager.cpp - shared/FirstSharedMemoryManager.h - shared/MemoryManager.cpp - shared/MemoryManager.h -) - -if(WIN32) - set(PLATFORM_SOURCES - win32/OsMemory.cpp - win32/OsMemory.h - win32/OsNewDel.cpp - win32/OsNewDel.h - ) - - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/win32) -else() - set(PLATFORM_SOURCES - linux/OsMemory.cpp - linux/OsMemory.h - linux/OsNewDel.cpp - linux/OsNewDel.h - ) - - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/linux) -endif() - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/shared - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public -) - -add_library(sharedMemoryManager STATIC - ${SHARED_SOURCES} - ${PLATFORM_SOURCES} -) diff --git a/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp b/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp deleted file mode 100755 index 6a63523b..00000000 --- a/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// ====================================================================== -// -// OsMemory.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/OsMemory.h" - -// ====================================================================== - -void OsMemory::install() -{ -} - -// ---------------------------------------------------------------------- - -void OsMemory::remove() -{ -} - -// ---------------------------------------------------------------------- - -void *OsMemory::commit(void *, size_t bytes) -{ - return ::malloc(bytes); -} - -// ---------------------------------------------------------------------- - -bool OsMemory::free(void *addr, size_t) -{ - ::free(addr); - - return true; -} - -// ====================================================================== diff --git a/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h b/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h deleted file mode 100755 index 8bc52ae5..00000000 --- a/engine/shared/library/sharedMemoryManager/src/linux/OsMemory.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// OsMemory.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsMemory_H -#define INCLUDED_OsMemory_H - -// ====================================================================== - -class OsMemory -{ -public: - static void install(); - static void remove(); - - static void * reserve(size_t bytes); - static void * commit(void *addr, size_t bytes); - static bool free(void *addr, size_t bytes); - static bool protect(void *addr, size_t bytes, bool allowAccess); -}; - -// ====================================================================== - -#endif // INCLUDED_OsMemory_H - diff --git a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp b/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp deleted file mode 100755 index 8d6fb02e..00000000 --- a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// ====================================================================== -// -// OsNewDel.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== -/* -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/MemoryManager.h" -#include "sharedMemoryManager/OsNewDel.h" - -#include -#include -#include - -static MemoryManager memoryManager __attribute__ ((init_priority (101))); - -// ====================================================================== - -void *operator new(size_t size, MemoryManagerNotALeak) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), false, false); -} - -// ---------------------------------------------------------------------- - -void *operator new(std::size_t size) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), false, true); -} - -// ---------------------------------------------------------------------- - -void *operator new[](size_t size) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), true, true); -} - -// ---------------------------------------------------------------------- - -void *operator new(size_t size, const char *file, int line) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), false, true); -} - -// ---------------------------------------------------------------------- - -void *operator new[](size_t size, const char *file, int line) -{ - return MemoryManager::allocate(size, reinterpret_cast(__builtin_return_address(0)), true, true); -} - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer) throw() -{ - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer) throw() -{ - if (pointer) - MemoryManager::free(pointer, true); -} - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer, const char *file, int line) throw() -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer, const char *file, int line) throw() -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, true); -} -*/ -// ====================================================================== - diff --git a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h b/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h deleted file mode 100755 index a1e0a64c..00000000 --- a/engine/shared/library/sharedMemoryManager/src/linux/OsNewDel.h +++ /dev/null @@ -1,37 +0,0 @@ -// ====================================================================== -// -// OsNewDel.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsNewDel_H -#define INCLUDED_OsNewDel_H - -// ====================================================================== -#include - -enum MemoryManagerNotALeak -{ - MM_notALeak -}; - -/* -void *operator new(size_t size, MemoryManagerNotALeak); -void *operator new(size_t size); -void *operator new[](std::size_t size); -void *operator new(size_t size, char const *file, int line); -void *operator new[](size_t size, char const *file, int line); - - -void operator delete(void *pointer) throw(); -void operator delete[](void *pointer) throw(); -void operator delete(void *pointer, char const *file, int line) throw(); -void operator delete[](void *pointer, char const *file, int line) throw(); -*/ - -// ====================================================================== - -#endif // INCLUDED_OsNewDel_H - diff --git a/engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.cpp b/engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.cpp deleted file mode 100755 index d1d100b2..00000000 --- a/engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// ====================================================================== -// -// FirstMemoryManager.cpp -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" diff --git a/engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.h b/engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.h deleted file mode 100755 index 0beb0fc5..00000000 --- a/engine/shared/library/sharedMemoryManager/src/shared/FirstSharedMemoryManager.h +++ /dev/null @@ -1,19 +0,0 @@ -// ====================================================================== -// -// FirstMemoryManager.h -// copyright (c) 2001 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_FirstMemoryManager_H -#define INCLUDED_FirstMemoryManager_H - -// ====================================================================== - -#include "sharedFoundationTypes/FoundationTypes.h" -#include "sharedDebug/FirstSharedDebug.h" -#include "sharedFoundation/FirstSharedFoundation.h" - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp b/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp deleted file mode 100755 index cbf83b1e..00000000 --- a/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.cpp +++ /dev/null @@ -1,2180 +0,0 @@ -// ====================================================================== -// -// MemoryManager.cpp -// Portions copyright 1998 Bootprint Entertainment -// Portions copyright 2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/MemoryManager.h" -#include "sharedMemoryManager/OsMemory.h" - -#include "sharedFoundation/ConfigSharedFoundation.h" -#include "sharedFoundation/Production.h" -#include "sharedDebug/DebugFlags.h" -#include "sharedDebug/DebugMonitor.h" -#include "sharedDebug/PixCounter.h" -#include "sharedDebug/Profiler.h" -#include "sharedSynchronization/RecursiveMutex.h" -#include "sharedDebug/RemoteDebug.h" - -#include - -#ifdef _WIN32 -#include -#include -#else -#include -#endif - -#include -#include -#include -#include - -// the below seems to bare minimum cause the DB process to segfault -// too bad, if we weren't using an omnibus mem manager we could potentially maximize usage -#define DISABLE_MEMORY_MANAGER 1 - -//lint -e826 // Suspicious pointer-to-pointer conversion (area too small) - -#if !DISABLE_MEMORY_MANAGER - -// ====================================================================== - -// this flag is different than above, as it doesn't fully disable the manager, only a few pieces -// including the destructor for some reason -#define DISABLED 1 - -// removed all the debug cases for these as these seem to cause problems -// recent modifications force the mem manager to always behave in production mode -// other areas will remain unaffected -#define DO_TRACK 0 -#define DO_SCALAR 0 -#define DO_GUARDS 0 -#define DO_INITIALIZE_FILLS 0 -#define DO_FREE_FILLS 0 - -// ====================================================================== - -namespace MemoryManagerNamespace -{ - class Block; - - class SystemAllocation - { - public: - - SystemAllocation(int size); - ~SystemAllocation(); - - int getSize(); - - SystemAllocation * getNext(); - void setNext(SystemAllocation *); - - Block * getFirstMemoryBlock(); - Block * getLastMemoryBlock(); - - private: - - int m_size; - SystemAllocation * m_next; - int m_pad1; - int m_pad2; - }; - - - class Block - { - public: - - enum { cms_requestedSizeBits = 30 }; - - public: - - Block * getPrevious(); - Block const * getPrevious() const; - void setPrevious(Block *previous); - - Block * getNext(); - Block const * getNext() const; - void setNext(Block *previous); - - bool isFree() const; - void setFree(bool free); - - int getSize() const; - - private: - - Block * m_previous; - Block * m_next; - bool m_free:1; - - protected: - - // these are only in allocated blocks, but we can't expect a compiler to merge bitfields across multiple classes -#if DO_SCALAR - bool m_array:1; -#endif -#if DO_TRACK - bool m_leakTest:0; -#endif -#if DO_TRACK || DO_GUARDS - unsigned int m_requestedSize:cms_requestedSizeBits; -#endif - }; - - class FreeBlock; - - void addToFreeList(Block * block); - void removeFromFreeList(FreeBlock * block); - FreeBlock *searchFreeList(int blockSize); - - class FreeBlock : public Block - { - private: - - friend void addToFreeList(Block *block); - friend void removeFromFreeList(FreeBlock *block); - friend FreeBlock *searchFreeList(int blockSize); - - private: - FreeBlock * m_smallerFreeBlock; - FreeBlock * m_sameFreeBlock; - FreeBlock * m_largerFreeBlock; - FreeBlock * m_parentFreeBlock; - }; - - class AllocatedBlock : public Block - { - public: - -#if DO_SCALAR - bool isAllocatedAsArray() const; - void setAllocatedAsArray(bool array); -#endif - -#if DO_TRACK - bool checkForLeaks() const; - void setCheckForLeaks(bool checkForLeaks); - - uint32 getOwner(int index) const; - void setOwner(int index, uint32 owner); - void fillOwnerWithFreePattern(); - -#endif - -#if DO_TRACK || DO_GUARDS - int getRequestedSize() const; - void setRequestedSize(int requestedSize); -#endif - - private: - -#if DO_TRACK - uint32 m_owner[DO_TRACK]; -#endif - }; - -#ifdef _DEBUG - void logAllocationsNextFrame(); -#endif - - int convertBytesToMegabytesForSystemAllocation(int bytes); - void allocateSystemMemory(int megabytes); - - int min(int a, int b); - int max(int a, int b); - byte const * min(byte const * a, byte const * b); - byte const * max(byte const * a, byte const * b); - - int report(bool leak); - void report(AllocatedBlock const * block, bool leak); - - int quickGuessIsValidPointerFromHeap(void const *); - int authoritativeIsValidPointerFromHeap(void const *); - - void emitCharacters(char * & buffer, int blockSize, int & carryOverFree, int & carryOverUsed, int newFree, int newUsed, char const * const bufferOverrunAddress); - - bool reportToFile(char const *fileName, bool leak); - void outputDebugStringWrapper(char const * message); - void logMessageToFd(char const * message); - - int const cms_blockSize = (sizeof(Block) + 15) & (~15); - int const cms_freeBlockSize = (sizeof(FreeBlock) + 15) & (~15); - extern int const cms_allocatedBlockSize = (sizeof(AllocatedBlock) + 15) & (~15); - byte const cms_guardFillPattern = 0xAB; - byte const cms_initializeFillPattern = 0xCD; - byte const cms_freeFillPattern = 0xEF; - int const cms_guardBandSize = DO_GUARDS ? 16 : 0; - - int const cms_systemAllocationRoundSize = 4 * 1024 * 1024; - int const cms_systemAllocationMinimumSize = 4 * 1024 * 1024; - - bool ms_installed; - bool ms_limitSet; - bool ms_hardLimit; - int ms_limitMegabytes = 3071; - SystemAllocation * ms_firstSystemAllocation; - int ms_numberOfSystemAllocations; - int ms_systemMemoryAllocatedMegabytes; - bool ms_reportAllocations; - -#ifdef _DEBUG - PixCounter::ResetInteger ms_allocationsPerFrame; - PixCounter::ResetInteger ms_bytesAllocatedPerFrame; - PixCounter::ResetInteger ms_freesPerFrame; - PixCounter::ResetInteger ms_bytesFreedPerFrame; - - bool ms_debugReportFlag; - bool ms_debugReportMapFlag; - bool ms_debugReportAllocations; - bool ms_debugReportLogMemoryAllocFreePointers; - bool ms_debugLogAllocations; - bool ms_debugLogAllocationsNextFrame; - bool ms_debugVerifyGuardPatterns; - bool ms_debugVerifyFreePatterns; - bool ms_debugProfileAllocate; - bool ms_debugLogAllocationsNextFrameStarted; -#endif - - RecursiveMutex * ms_criticalSection; - - char ms_memoryManagerBuffer[sizeof(MemoryManager)]; - - FreeBlock * ms_firstFreeBlock; - - int ms_allocateCalls; - unsigned long ms_allocateBytesTotal; -#ifndef _WIN32 - int ms_processVmSizeKBytes; -#endif - int ms_freeCalls; - - int ms_allocations; - int ms_maxAllocations; - - int ms_freeBlocks; - int ms_maxFreeBlocks; -#ifdef _DEBUG - int ms_maxTreeHeight; -#endif - -#if DO_TRACK || DO_GUARDS - unsigned long ms_currentBytesRequested; -#endif - unsigned long ms_currentBytesAllocated; -#if DO_TRACK - unsigned long ms_currentBytesAllocatedNoLeakTest; -#endif - unsigned long ms_maxBytesAllocated; - - bool ms_allowNameLookup = true; - int ms_logMessageFd = -1; - void (*LogMessage)(char const * message) = &outputDebugStringWrapper; - - PROFILER_BLOCK_DEFINE(ms_allocateProfilerBlock, "MemoryManager::allocate"); -} -using namespace MemoryManagerNamespace; - -// ====================================================================== - -SystemAllocation::SystemAllocation(int size) -: - m_size(size), - m_next(nullptr), - m_pad1(0), - m_pad2(0) -{ - DEBUG_FATAL(sizeof(*this) != cms_blockSize, ("SystemAllocation size is not %d bytes", cms_blockSize)); - -#if DO_FREE_FILLS - // fill the newly allocated user memory with the free pattern - imemset(reinterpret_cast(this) + cms_blockSize, cms_freeFillPattern, m_size - cms_blockSize); -#endif - - Block * firstMemoryBlock = getFirstMemoryBlock(); - Block * firstFreeBlock = reinterpret_cast(reinterpret_cast(firstMemoryBlock) + cms_blockSize); - Block * lastMemoryBlock = getLastMemoryBlock(); - - // set up the prefix sentinel block - firstMemoryBlock->setPrevious(nullptr); - firstMemoryBlock->setNext(firstFreeBlock); - firstMemoryBlock->setFree(false); - - firstFreeBlock->setPrevious(firstMemoryBlock); - firstFreeBlock->setNext(lastMemoryBlock); - firstFreeBlock->setFree(true); - - // set up the suffix sentinel block - lastMemoryBlock->setPrevious(firstFreeBlock); - lastMemoryBlock->setNext(nullptr); - lastMemoryBlock->setFree(false); - - // put the first block on the free list - addToFreeList(firstFreeBlock); -} - -// ---------------------------------------------------------------------- - -SystemAllocation::~SystemAllocation() -{ - OsMemory::free(this, m_size); -} - -// ---------------------------------------------------------------------- - -int SystemAllocation::getSize() -{ - return m_size; -} - -// ---------------------------------------------------------------------- - -SystemAllocation * SystemAllocation::getNext() -{ - return m_next; -} - -// ---------------------------------------------------------------------- - -void SystemAllocation::setNext(SystemAllocation * next) -{ - m_next = next; -} - -// ---------------------------------------------------------------------- - -Block * SystemAllocation ::getFirstMemoryBlock() -{ - return reinterpret_cast(reinterpret_cast(this) + cms_blockSize); -} - -// ---------------------------------------------------------------------- - -Block * SystemAllocation ::getLastMemoryBlock() -{ - return reinterpret_cast(reinterpret_cast(this) + m_size - cms_blockSize); -} - -// ====================================================================== - -inline Block * Block::getPrevious() -{ - return m_previous; -} - -// ---------------------------------------------------------------------- - -inline Block const * Block::getPrevious() const -{ - return m_previous; -} - -// ---------------------------------------------------------------------- - -inline void Block::setPrevious(Block *previous) -{ - m_previous = previous; -} - -// ---------------------------------------------------------------------- - -inline Block * Block::getNext() -{ - return m_next; -} - -// ---------------------------------------------------------------------- - -inline Block const * Block::getNext() const -{ - return m_next; -} - -// ---------------------------------------------------------------------- - -inline void Block::setNext(Block *next) -{ - DEBUG_FATAL(next && reinterpret_cast(next) - reinterpret_cast(this) < cms_blockSize, ("too small")); - m_next = next; -} - -// ---------------------------------------------------------------------- - -inline bool Block::isFree() const -{ - return m_free; -} - -// ---------------------------------------------------------------------- - -inline void Block::setFree(bool free) -{ - m_free = free; -} - -// ---------------------------------------------------------------------- - -inline int Block::getSize() const -{ - return reinterpret_cast(m_next) - reinterpret_cast(this); -} - -// ====================================================================== - -#if DO_SCALAR - -inline bool AllocatedBlock::isAllocatedAsArray() const -{ - return m_array; -} - -// ---------------------------------------------------------------------- - -inline void AllocatedBlock::setAllocatedAsArray(bool array) -{ - m_array = array; -} - -#endif - -// ---------------------------------------------------------------------- - -#if DO_TRACK - -inline bool AllocatedBlock::checkForLeaks() const -{ - return m_leakTest; -} - -// ---------------------------------------------------------------------- - -inline void AllocatedBlock::setCheckForLeaks(bool checkForLeaks) -{ - m_leakTest = checkForLeaks; -} - -// ---------------------------------------------------------------------- - -inline uint32 AllocatedBlock::getOwner(int index) const -{ - return m_owner[index]; -} - -// ---------------------------------------------------------------------- - -inline void AllocatedBlock::setOwner(int index, uint32 owner) -{ - m_owner[index] = owner; -} - -// ---------------------------------------------------------------------- - -inline void AllocatedBlock::fillOwnerWithFreePattern() -{ - memset(m_owner, cms_freeFillPattern, sizeof(m_owner)); -} - -#endif - -// ---------------------------------------------------------------------- - -#if DO_TRACK || DO_GUARDS - -inline int AllocatedBlock::getRequestedSize() const -{ - return m_requestedSize; -} - -// ---------------------------------------------------------------------- - -inline void AllocatedBlock::setRequestedSize(int requestedSize) -{ - m_requestedSize = requestedSize; -} - -#endif - -// ====================================================================== - -inline int MemoryManagerNamespace::min(int a, int b) -{ - return (a < b) ? a : b; -} - -// ---------------------------------------------------------------------- - -inline int MemoryManagerNamespace::max(int a, int b) -{ - return (a > b) ? a : b; -} - -// ---------------------------------------------------------------------- - -inline byte const * MemoryManagerNamespace::min(byte const * a, byte const * b) -{ - return (a < b) ? a : b; -} - -// ---------------------------------------------------------------------- - -inline byte const * MemoryManagerNamespace::max(byte const * a, byte const * b) -{ - return (a > b) ? a : b; -} - -// ---------------------------------------------------------------------- -// this is here to get around linkage problems on win32 - -void MemoryManagerNamespace::outputDebugStringWrapper(char const * message) -{ - OutputDebugString(message); -} - -// ---------------------------------------------------------------------- - -void MemoryManager::setLimit(int megabytes, bool hardLimit, bool preallocate) -{ - DEBUG_FATAL(ms_limitSet, ("MemoryManager::setLimit may only be called once")); - ms_limitSet = true; - ms_limitMegabytes = megabytes; - ms_hardLimit = hardLimit; - DEBUG_FATAL(ms_hardLimit && ms_systemMemoryAllocatedMegabytes > ms_limitMegabytes, ("hard limit broken before being set %d/%d", ms_systemMemoryAllocatedMegabytes, ms_limitMegabytes)); - if (preallocate && ms_systemMemoryAllocatedMegabytes < ms_limitMegabytes) - allocateSystemMemory(ms_limitMegabytes - ms_systemMemoryAllocatedMegabytes); -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getLimit() -{ - return ms_limitMegabytes; -} - -// ---------------------------------------------------------------------- - -bool MemoryManager::isHardLimit() -{ - return ms_hardLimit; -} - -// ---------------------------------------------------------------------- -/** - * Install the MemoryManager. - * @param newMaxBytes Maximum number of bytes in the memory pool - * @param newMaxBlocks Number of blocks (free or allocated) - * @param commitAll Commit all the specified ram to the application - */ - -MemoryManager::MemoryManager() -{ - // any allocation will install the memory manager if it has yet to be, so we want to bail safely here - if (ms_installed) - return; - -#if defined(PLATFORM_WIN32) && defined(_DEBUG) - /* - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW); - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW); - int crtHeapFlags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - crtHeapFlags &= ~_CRTDBG_ALLOC_MEM_DF; - crtHeapFlags &= ~_CRTDBG_CHECK_ALWAYS_DF; - crtHeapFlags &= ~_CRTDBG_CHECK_CRT_DF; - crtHeapFlags &= ~_CRTDBG_DELAY_FREE_MEM_DF; - crtHeapFlags &= ~_CRTDBG_LEAK_CHECK_DF; - _CrtSetDbgFlag(crtHeapFlags); - */ -#endif - - OsMemory::install(); - DebugHelp::install(); - -#if !DISABLED - - // this buffer must remain local to this function, otherwise it will get clobbered. - // the problem is this function gets called before the library gets properly initialized, - // and then when the library gets initialized, it will clear the global memory, thus - // wiping out our mutex. - static char s_criticalSectionBuffer[sizeof(RecursiveMutex)]; - ms_criticalSection = new(s_criticalSectionBuffer) RecursiveMutex; - - ms_reportAllocations = true; - ms_installed = true; -// ms_logEachAlloc = false; - -#endif -} - -// ---------------------------------------------------------------------- -/** - * Remove the MemoryManager. - */ - -MemoryManager::~MemoryManager() -{ -#if DISABLED - return; -#else - - DEBUG_FATAL(!ms_installed, ("not installed")); - - ms_criticalSection->enter(); - - DEBUG_REPORT_LOG_PRINT(true, ("MM::remove %lu/%lu=bytes %d/%d=allocs\n", getCurrentNumberOfBytesAllocated(), getMaximumNumberOfBytesAllocated(), getCurrentNumberOfAllocations(), getMaximumNumberOfAllocations())); - DEBUG_OUTPUT_CHANNEL("Foundation\\MemoryManager", ("MM::remove %lu/%lu=bytes %d/%d=allocs\n", getCurrentNumberOfBytesAllocated(), getMaximumNumberOfBytesAllocated(), getCurrentNumberOfAllocations(), getMaximumNumberOfAllocations())); - -#if DO_TRACK - if (!ConfigSharedFoundation::getDemoMode() && ms_allocations && ms_reportAllocations) - { - ms_criticalSection->leave(); - int const leaks = MemoryManagerNamespace::report(true); - ms_criticalSection->enter(); - if (leaks) - REPORT(true, Report::RF_log | Report::RF_dialog, ("%d memory leak%s", leaks, leaks > 1 ? "s" : "")); - } -#endif - - // free all of the allocations from the OS - while (ms_firstSystemAllocation) - { - SystemAllocation * systemAllocation = ms_firstSystemAllocation; - ms_firstSystemAllocation = ms_firstSystemAllocation->getNext(); - systemAllocation->~SystemAllocation(); - } - - ms_criticalSection->leave(); - ms_installed = false; - -#ifdef _DEBUG - DebugMonitor::remove(); -#endif - - ms_criticalSection->~RecursiveMutex(); - -#endif - - DebugHelp::remove(); - OsMemory::remove(); -} - -// ---------------------------------------------------------------------- - -int MemoryManagerNamespace::convertBytesToMegabytesForSystemAllocation(int systemAllocationSize) -{ - if (systemAllocationSize < cms_systemAllocationMinimumSize) - systemAllocationSize = cms_systemAllocationMinimumSize; - - systemAllocationSize = (systemAllocationSize + (cms_systemAllocationRoundSize - 1)) & (~(cms_systemAllocationRoundSize - 1)); - - return systemAllocationSize / (1024 * 1024); -} - -// ---------------------------------------------------------------------- - -void MemoryManagerNamespace::allocateSystemMemory(int megabytes) -{ - if (ms_hardLimit && ms_systemMemoryAllocatedMegabytes + megabytes > ms_limitMegabytes) - { - megabytes = ms_limitMegabytes - ms_systemMemoryAllocatedMegabytes; - if (megabytes <= 0) - return; - } - - // allocate the system memory - size_t systemAllocationSize = static_cast(megabytes) * 1024 * 1024; - void * data = OsMemory::commit(0, systemAllocationSize); - - // failed to allocate virtual memory. there is insufficient virtual memory or address space to satisfy systemAllocationSize. - if (!data) - return; - - // Construct our tracking information - SystemAllocation * systemAllocation = new(data) SystemAllocation(systemAllocationSize); - ++ms_numberOfSystemAllocations; - ms_systemMemoryAllocatedMegabytes += megabytes; - - // insert the memory into the sorted linked list of system allocations - SystemAllocation * back = nullptr; - SystemAllocation * front = ms_firstSystemAllocation; - for ( ; front && front->getFirstMemoryBlock() < systemAllocation->getFirstMemoryBlock(); back = front, front = front->getNext()) - {} - if (back) - back->setNext(systemAllocation); - else - ms_firstSystemAllocation = systemAllocation; - systemAllocation->setNext(front); -} - -// ---------------------------------------------------------------------- - -unsigned long MemoryManager::getCurrentNumberOfBytesAllocated(const int processId) -{ - UNREF(processId); - return ms_currentBytesAllocated; -} - -// ---------------------------------------------------------------------- - -unsigned long MemoryManager::getCurrentNumberOfBytesAllocatedNoLeakTest() -{ -#if DO_TRACK - return ms_currentBytesAllocatedNoLeakTest; -#else - return 0; -#endif -} - -// ---------------------------------------------------------------------- - -unsigned long MemoryManager::getMaximumNumberOfBytesAllocated() -{ - return ms_maxBytesAllocated; -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getSystemMemoryAllocatedMegabytes() -{ - return ms_systemMemoryAllocatedMegabytes; -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getCurrentNumberOfAllocations() -{ - return ms_allocations; -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getMaximumNumberOfAllocations() -{ - return ms_maxAllocations; -} - -// ---------------------------------------------------------------------- - -void MemoryManager::setReportAllocations(bool reportAllocations) -{ - ms_reportAllocations = reportAllocations; -} - -// ---------------------------------------------------------------------- - -void MemoryManager::registerDebugFlags() -{ -#ifdef _DEBUG - DebugFlags::registerFlag(ms_debugReportFlag, "SharedMemoryManager", "reportMemory", debugReport); - DebugFlags::registerFlag(ms_debugReportMapFlag, "SharedMemoryManager", "reportMemoryMap", debugReportMap); - DebugFlags::registerFlag(ms_debugReportAllocations, "SharedMemoryManager", "reportMemoryAllocations"); - DebugFlags::registerFlag(ms_debugReportLogMemoryAllocFreePointers, "SharedMemoryManager", "reportLogMemoryAllocFreePointers"); - DebugFlags::registerFlag(ms_debugLogAllocations, "SharedMemoryManager", "reportLogAllocations"); - DebugFlags::registerFlag(ms_debugLogAllocationsNextFrame, "SharedMemoryManager", "reportLogAllocationsNextFrame", logAllocationsNextFrame); - DebugFlags::registerFlag(ms_debugVerifyGuardPatterns, "SharedMemoryManager", "verifyGuardPatterns"); - DebugFlags::registerFlag(ms_debugVerifyFreePatterns, "SharedMemoryManager", "verifyFreePatterns"); - DebugFlags::registerFlag(ms_debugProfileAllocate, "SharedMemoryManager", "profileAllocate"); -#endif -} - -// ---------------------------------------------------------------------- -/** - * Dump debugging information about the MemoryManager. - */ - -void MemoryManager::debugReport() -{ -#if !DISABLED - DEBUG_FATAL(!ms_installed, ("not installed")); - DEBUG_REPORT_PRINT(ms_limitSet, ("MM: %9dmb (%s limit)\n", ms_limitMegabytes, ms_hardLimit ? "hard" : "soft")); - DEBUG_REPORT_PRINT(true, ("MM: %9d/%9d/%9d cur/max/tot allocs\n", ms_allocations, ms_maxAllocations, ms_allocateCalls)); - DEBUG_REPORT_PRINT(true, ("MM: %9lu/%9lu/%9lu cur/max/tot bytes\n", ms_currentBytesAllocated, ms_maxBytesAllocated, ms_allocateBytesTotal)); -#endif -} - -// ---------------------------------------------------------------------- - -#ifdef _DEBUG -void MemoryManagerNamespace::logAllocationsNextFrame() -{ - if (!ms_debugLogAllocationsNextFrameStarted) - { - REPORT_LOG_PRINT(true, ("MemoryManager::logAllocationsNextFrame start\n")); - ms_debugLogAllocations = true; - ms_debugLogAllocationsNextFrameStarted = true; - } - else - { - REPORT_LOG_PRINT(true, ("MemoryManager::logAllocationsNextFrame end\n")); - ms_debugLogAllocations = false; - ms_debugLogAllocationsNextFrameStarted = false; - ms_debugLogAllocationsNextFrame = false; - } -} -#endif - -// ---------------------------------------------------------------------- - -void MemoryManagerNamespace::emitCharacters(char * & buffer, int blockSize, int & carryOverFree, int & carryOverUsed, int newFree, int newUsed, char const * const bufferOverrunAddress) -{ - while (carryOverFree + carryOverUsed + newFree + newUsed >= blockSize) - { - int const absorbNew = blockSize - (carryOverUsed + carryOverFree); - if (newFree) - { - carryOverFree += absorbNew; - newFree -= absorbNew; - } - else - { - carryOverUsed += absorbNew; - newUsed -= absorbNew; - } - - if (carryOverFree == blockSize) - *buffer = '_'; - else - if (carryOverUsed == blockSize) - *buffer = '*'; - else - { - int const letter = (carryOverUsed * 26) / blockSize; - *buffer = static_cast('A' + letter); - } - ++buffer; - - FATAL(buffer == bufferOverrunAddress, ("Buffer overrun! 0x%0X", buffer)); - - carryOverFree = 0; - carryOverUsed = 0; - } - - carryOverFree += newFree; - carryOverUsed += newUsed; -} - -// ---------------------------------------------------------------------- -/** - * Dump an image of the memory state to the report system. - */ - -void MemoryManager::debugReportMap() -{ - for (SystemAllocation * systemAllocation = ms_firstSystemAllocation; systemAllocation; systemAllocation = systemAllocation->getNext()) - { - char buffer[128]; - int const numberOfCharactersPerRow = 64; - - snprintf(buffer, sizeof(buffer)-1, "%8p %3dmb : ", systemAllocation, systemAllocation->getSize() / (1024 * 1024)); - buffer[sizeof(buffer)-1] = '\0'; - - int const headerLength = strlen(buffer); - int const characterSize = systemAllocation->getSize() / numberOfCharactersPerRow; - - int carryOverUsed = 0; - int carryOverFree = 0; - char * b = buffer + headerLength; - char const * const bufferOverrunAddress = buffer + sizeof(buffer); - for (Block * block = systemAllocation->getFirstMemoryBlock()->getNext(); block != systemAllocation->getLastMemoryBlock(); block = block->getNext()) - { - if (block->isFree()) - emitCharacters(b, characterSize, carryOverFree, carryOverUsed, block->getSize(), 0, bufferOverrunAddress); - else - emitCharacters(b, characterSize, carryOverFree, carryOverUsed, 0, block->getSize(), bufferOverrunAddress); - } - - if (carryOverFree || carryOverUsed) - emitCharacters(b, carryOverFree + carryOverUsed, carryOverFree, carryOverUsed, 0, 0, bufferOverrunAddress); - - b[0] = '\0'; - - DEBUG_REPORT_PRINT(true, ("%s\n", buffer)); - } -} - -// ---------------------------------------------------------------------- -/** - * Add a block to the free memory chain list. - * - * @param block Block of memory that is being - */ - -void MemoryManagerNamespace::addToFreeList(Block * block) -{ - NOT_NULL(block); - - // @todo consider making the ternary search tree balanced - - FreeBlock * freeBlock = static_cast(block); - int const freeBlockSize = freeBlock->getSize(); - FreeBlock * parent = nullptr; - FreeBlock * * next = &ms_firstFreeBlock; - FreeBlock * same = 0; - - for (FreeBlock * current = ms_firstFreeBlock; current; parent = current, current = *next) - { - int const currentBlockSize = current->getSize(); - if (freeBlockSize < currentBlockSize) - next = ¤t->m_smallerFreeBlock; - else - if (freeBlockSize > currentBlockSize) - next = ¤t->m_largerFreeBlock; - else - { - // quick out for same size blocks - same = current; - break; - } - } - - if (same) - { - - freeBlock->m_smallerFreeBlock = same->m_smallerFreeBlock; - same->m_smallerFreeBlock = nullptr; - if (freeBlock->m_smallerFreeBlock) - freeBlock->m_smallerFreeBlock->m_parentFreeBlock = freeBlock; - - freeBlock->m_sameFreeBlock = same; - same->m_parentFreeBlock = freeBlock; - - freeBlock->m_largerFreeBlock = same->m_largerFreeBlock; - same->m_largerFreeBlock = nullptr; - if (freeBlock->m_largerFreeBlock) - freeBlock->m_largerFreeBlock->m_parentFreeBlock = freeBlock; - - *next = freeBlock; - freeBlock->m_parentFreeBlock = parent; - } - else - { - *next = freeBlock; - freeBlock->m_smallerFreeBlock = nullptr; - freeBlock->m_sameFreeBlock = nullptr; - freeBlock->m_largerFreeBlock = nullptr; - freeBlock->m_parentFreeBlock = parent; - } - - if (++ms_freeBlocks > ms_maxFreeBlocks) - ms_maxFreeBlocks = ms_freeBlocks; - -#ifdef _DEBUG - int treeHeight = 0; - while (freeBlock) - { - ++treeHeight; - freeBlock = freeBlock->m_parentFreeBlock; - } - if (treeHeight > ms_maxTreeHeight) - ms_maxTreeHeight = treeHeight; -#endif -} - -// ---------------------------------------------------------------------- -/** - * Remove a block from the free memory chain list. - * - * @param block Block of memory that is being allocated - */ - -void MemoryManagerNamespace::removeFromFreeList(FreeBlock * block) -{ - NOT_NULL(block); - - // find the pointer that points to block - FreeBlock * * parentPointer = nullptr; - FreeBlock * parent = block->m_parentFreeBlock; - if (parent) - { - if (parent->m_smallerFreeBlock == block) - parentPointer = &parent->m_smallerFreeBlock; - else - if (parent->m_sameFreeBlock == block) - parentPointer = &parent->m_sameFreeBlock; - else - { - DEBUG_FATAL(parent->m_largerFreeBlock != block, ("parent doesn't know about child")); - parentPointer = &parent->m_largerFreeBlock; - } - } - else - { - DEBUG_FATAL(ms_firstFreeBlock != block, ("no parent but not first")); - parentPointer = &ms_firstFreeBlock; - } - - // now we need to replace our node with one from underneath us - FreeBlock * same = block->m_sameFreeBlock; - if (same) - { - // making use of the same size block is pretty easy and doesn't disturb tree balance so its our prefered choice - same->m_smallerFreeBlock = block->m_smallerFreeBlock; - if (same->m_smallerFreeBlock) - same->m_smallerFreeBlock->m_parentFreeBlock = same; - - same->m_largerFreeBlock = block->m_largerFreeBlock; - if (same->m_largerFreeBlock) - same->m_largerFreeBlock->m_parentFreeBlock = same; - - same->m_parentFreeBlock = parent; - - *parentPointer = same; - } - else - { - if (block->m_smallerFreeBlock) - { - if (block->m_largerFreeBlock) - { - // this is the worst case. this free block has smaller and larger children, but not any same sized children - // we're going to take the smallest block off the larger list and use that to replace the current node - FreeBlock * back = nullptr; - FreeBlock * replacement = block->m_largerFreeBlock; - while (replacement->m_smallerFreeBlock) - { - back = replacement; - replacement = replacement->m_smallerFreeBlock; - } - - // disconnect the link between its parent and out replacement block - if (back) - { - back->m_smallerFreeBlock = replacement->m_largerFreeBlock; - if (back->m_smallerFreeBlock) - back->m_smallerFreeBlock->m_parentFreeBlock = back; - - replacement->m_largerFreeBlock = block->m_largerFreeBlock; - replacement->m_largerFreeBlock->m_parentFreeBlock = replacement; - } - - // put the replacement block in its new place - replacement->m_smallerFreeBlock = block->m_smallerFreeBlock; - replacement->m_smallerFreeBlock->m_parentFreeBlock = replacement; - - replacement->m_parentFreeBlock = parent; - - *parentPointer = replacement; - } - else - { - // this block only has one child, which is smaller. an easy case. - block->m_smallerFreeBlock->m_parentFreeBlock = parent; - *parentPointer = block->m_smallerFreeBlock; - } - } - else - { - if (block->m_largerFreeBlock) - { - // this block only has one child, which is larger. an easy case. - block->m_largerFreeBlock->m_parentFreeBlock = parent; - *parentPointer = block->m_largerFreeBlock; - } - else - { - // this block has no children - *parentPointer = nullptr; - } - } - } - - // remove all the pointers the block may have had - block->m_smallerFreeBlock = nullptr; - block->m_sameFreeBlock = nullptr; - block->m_largerFreeBlock = nullptr; - block->m_parentFreeBlock = nullptr; - - --ms_freeBlocks; -} - -// ---------------------------------------------------------------------- - -FreeBlock *MemoryManagerNamespace::searchFreeList(int blockSize) -{ - FreeBlock * result = nullptr; - FreeBlock * current = ms_firstFreeBlock; - while (current) - { - int const currentBlockSize = current->getSize(); - - if (currentBlockSize < blockSize) - { - // this block is too small so check blocks larger than this - current = current->m_largerFreeBlock; - } - else - if (currentBlockSize > blockSize) - { - // this block is too large but will be the best fit so far. continue checking smaller blocks. - result = current; - current = current->m_smallerFreeBlock; - } - else - { - // this block is a perfect fit, return it immediately. - return current; - } - } - - return result; -} - -// ---------------------------------------------------------------------- -/** - * Dynamically allocate memory. - * - * Users should not call this routine directly. It should only be called - * by operator new. - * - * @param size Number of bytes to allocate - * @param owner Line number on which the allocation was made - * @param array True if the array form of operator new was used, false if the scalar form was used - */ - -void * MemoryManager::allocate(size_t size, uint32 owner, bool array, bool leakTest) -{ - if (!ms_installed) - new(ms_memoryManagerBuffer) MemoryManager; - - UNREF(owner); - UNREF(array); - UNREF(leakTest); - -#if DISABLED - return operator new(size); -#else - - DEBUG_FATAL(!ms_installed, ("not installed")); - -#ifdef _DEBUG - if (ms_debugProfileAllocate) - PROFILER_BLOCK_ENTER(ms_allocateProfilerBlock); - - if (ms_debugVerifyGuardPatterns || ms_debugVerifyFreePatterns) - verify(ms_debugVerifyGuardPatterns, ms_debugVerifyFreePatterns); - - if (ms_debugReportAllocations || ms_debugLogAllocations) - { - char libName[256]; - char fileName[256]; - int line; - if (ms_allowNameLookup && DebugHelp::lookupAddress(owner, libName, fileName, sizeof(fileName), line)) - { - DEBUG_REPORT(true, (ms_debugReportAllocations ? Report::RF_print : 0) | (ms_debugLogAllocations ? Report::RF_log : 0), ("%s(%d): alloc %d=bytes %d=array\n", fileName, line, size, static_cast(array))); - } - else - { - DEBUG_REPORT(true, (ms_debugReportAllocations ? Report::RF_print : 0) | (ms_debugLogAllocations ? Report::RF_log : 0), ("%08x: alloc %d=bytes %d=array\n", static_cast(owner), size, static_cast(array))); - } - } -#endif - - ms_criticalSection->enter(); - - // get the size of the allocation - int allocSize = (cms_allocatedBlockSize + cms_guardBandSize + (size ? static_cast(size) : 1) + cms_guardBandSize + 15) & ~15; - - FreeBlock * bestFreeBlock = nullptr; - for (int tries = 0; !bestFreeBlock && tries < 2; ++tries) - { - bestFreeBlock = searchFreeList(allocSize); - - // if the memory allocation failed, try to get some more memory - if (!bestFreeBlock) - allocateSystemMemory(convertBytesToMegabytesForSystemAllocation(cms_blockSize + cms_blockSize + allocSize + cms_blockSize)); - } - - // make sure memory was available - if (!bestFreeBlock) - { - if (ConfigSharedFoundation::getMemoryManagerReportOnOutOfMemory()) - { - // avoid deadlock from FATAL calling free - (*LogMessage)("Out of memory, dumping current allocations:\n"); - IGNORE_RETURN(MemoryManagerNamespace::report(false)); - } - - ms_criticalSection->leave(); - FATAL(true, ("failed allocation attempt for %d (%d actual)", allocSize, size)); - } - - removeFromFreeList(bestFreeBlock); - - // setup the allocation record - bestFreeBlock->setFree(false); - - // check to see if we should subdivide this block - if (bestFreeBlock->getSize() > (allocSize + cms_allocatedBlockSize + cms_guardBandSize + 1 + cms_guardBandSize)) - { - Block *block = reinterpret_cast(reinterpret_cast(bestFreeBlock) + allocSize); - block->setPrevious(bestFreeBlock); - block->setNext(bestFreeBlock->getNext()); - block->setFree(true); - - bestFreeBlock->getNext()->setPrevious(block); - bestFreeBlock->setNext(block); - - addToFreeList(block); - } - - AllocatedBlock * best = reinterpret_cast(bestFreeBlock); - -#if DO_SCALAR - best->setAllocatedAsArray(array); -#endif - -#if DO_TRACK - best->setCheckForLeaks(leakTest); - best->setOwner(0, owner); -#endif -#if DO_TRACK > 1 - { - enum { OFFSET = 3 }; - uint32 owners[DO_TRACK + OFFSET]; - DebugHelp::getCallStack(owners, DO_TRACK + OFFSET); - - for (int i = 1; i < DO_TRACK; ++i) - { - best->setOwner(i, owners[i + OFFSET]); - -#ifdef _DEBUG - if (ms_debugReportAllocations || ms_debugLogAllocations) - { - char libName[256]; - char fileName[256]; - int line; - if (ms_allowNameLookup && DebugHelp::lookupAddress(owners[i + OFFSET], libName, fileName, sizeof(fileName), line)) - { - DEBUG_REPORT(true, (ms_debugReportAllocations ? Report::RF_print : 0) | (ms_debugLogAllocations ? Report::RF_log : 0), (" %s(%d): caller %d\n", fileName, line, i)); - } - else - { - DEBUG_REPORT(true, (ms_debugReportAllocations ? Report::RF_print : 0) | (ms_debugLogAllocations ? Report::RF_log : 0), (" %08x: caller %d\n", static_cast(owners[i + OFFSET]), i)); - } - } -#endif - } - } -#endif -#if DO_TRACK || DO_GUARDS - best->setRequestedSize(static_cast(size)); - ms_currentBytesRequested += size; - DEBUG_FATAL(best->getRequestedSize() != static_cast(size), ("allocated more memory at once than the memory manager supports (%d)", (1 << Block::cms_requestedSizeBits) - 1)); -#endif - - // update the size of the allocation because our block may not have been large enough to subdivide - allocSize = best->getSize(); - - // update the number of bytes allocated - ++ms_allocateCalls; - ms_allocateBytesTotal += allocSize; - ms_currentBytesAllocated += allocSize; - -#if DO_TRACK - if (!leakTest) - ms_currentBytesAllocatedNoLeakTest += allocSize; -#endif - - if (++ms_allocations > ms_maxAllocations) - ms_maxAllocations = ms_allocations; - if (ms_currentBytesAllocated > ms_maxBytesAllocated) - ms_maxBytesAllocated = ms_currentBytesAllocated; - - // get another pointer to the memory we allocated so we can tinker with it - byte * memory = reinterpret_cast(best) + cms_allocatedBlockSize + cms_guardBandSize; - -#if DO_GUARDS - // fill the prefix guard band - memset(memory - cms_guardBandSize, cms_guardFillPattern, cms_guardBandSize); -#endif - - // fill the user memory with the initialize pattern -#if DO_INITIALIZE_FILLS - memset(memory, cms_initializeFillPattern, size); -#endif - -#if DO_GUARDS - // fill the suffix guard band - memset(memory+size, cms_guardFillPattern, cms_guardBandSize); -#endif - - ms_criticalSection->leave(); - - DEBUG_REPORT_LOG_PRINT(ms_debugReportLogMemoryAllocFreePointers, ("MM::alloc %08x\n", reinterpret_cast(memory))); - -#ifdef _DEBUG - if (ms_debugProfileAllocate) - PROFILER_BLOCK_LEAVE(ms_allocateProfilerBlock); -#endif - -// DEBUG_REPORT_LOG(ms_logEachAlloc, ("MemoryManager::allocate() requested_size=%d, alloc_size=%d, ptr=%p\n", size, allocSize, memory)); - - return memory; -#endif -} - -// ---------------------------------------------------------------------- - -void *MemoryManager::reallocate(void *userPointer, size_t newSize) -{ - AllocatedBlock *allocatedBlock = 0; - bool array = false; - int oldSize = 0; - - if (userPointer) - { - allocatedBlock = reinterpret_cast(reinterpret_cast(userPointer) - (cms_allocatedBlockSize + cms_guardBandSize)); - #if DO_SCALAR - array = allocatedBlock->isAllocatedAsArray(); - #endif - if (!newSize) - { - MemoryManager::free(userPointer, array); - -// DEBUG_REPORT_LOG(ms_logEachAlloc, ("MemoryManager::reallocate() new_requested_size=%d, org ptr=%p, new ptr=nullptr\n", newSize, userPointer)); - - return 0; - } - #if DO_TRACK || DO_GUARDS - oldSize = allocatedBlock->getRequestedSize(); - #else - oldSize = allocatedBlock->getSize()-cms_allocatedBlockSize; - #endif - } - - if (newSize <= static_cast(oldSize)) - { -// DEBUG_REPORT_LOG(ms_logEachAlloc, ("realloc() new_requested_size=%d, org ptr=%p, new ptr=%p\n", newSize, userPointer, userPointer)); - - return userPointer; - } - -#if DO_TRACK - uint32 owner = allocatedBlock->getOwner(0); - bool leakTest = allocatedBlock->checkForLeaks(); -#else - uint32 owner = 0; - bool leakTest = false; -#endif - - void *newPointer = allocate(newSize, owner, array, leakTest); - if (oldSize) - memcpy(newPointer, userPointer, oldSize); - if (userPointer) - MemoryManager::free(userPointer, array); - -// DEBUG_REPORT_LOG(ms_logEachAlloc, ("MemoryManager::reallocate() new_requested_size=%d, org ptr=%p, new ptr=%p\n", newSize, userPointer, newPointer)); - - return newPointer; -} - -// ---------------------------------------------------------------------- -/** - * Free dynamically allocated memory. - * - * Users should not call this routine directly. It should only be called - * by operator delete. - * - * This routine should not be called with the nullptr pointer. - * - * @param userPointer Pointer to the memory - * @param array True if the array form of operator new was used, false if the scalar form was used - */ - -void MemoryManager::free(void * userPointer, bool array) -{ -#if DISABLED - UNREF(array); - operator delete(userPointer); - return; -#else - - DEBUG_FATAL(!ms_installed, ("not installed")); - NOT_NULL(userPointer); - -#ifdef _DEBUG - if (ms_debugVerifyGuardPatterns || ms_debugVerifyFreePatterns) - verify(ms_debugVerifyGuardPatterns, ms_debugVerifyFreePatterns); -#endif - - DEBUG_REPORT_LOG_PRINT(ms_debugReportLogMemoryAllocFreePointers, ("MM::free %08x\n", reinterpret_cast(userPointer))); - - UNREF(array); - - ms_criticalSection->enter(); - - AllocatedBlock * allocatedBlock = reinterpret_cast(reinterpret_cast(userPointer) - (cms_allocatedBlockSize + cms_guardBandSize)); - -#if DEBUG_LEVEL == DEBUG_LEVEL_DEBUG - DEBUG_FATAL(allocatedBlock->getNext()->getPrevious() != allocatedBlock, ("Bad free (1) %p", userPointer)); - DEBUG_FATAL(allocatedBlock->getPrevious()->getNext() != allocatedBlock, ("Bad free (2) %p", userPointer)); - DEBUG_FATAL(allocatedBlock->isFree(), ("Freeing already free block %p", userPointer)); -#endif - -#if DO_TRACK - ms_bytesFreedPerFrame += allocatedBlock->getRequestedSize(); -#endif - -#if DO_GUARDS - { - // verify the guard bands - byte * guard = reinterpret_cast(allocatedBlock) + cms_allocatedBlockSize; - bool corrupt = false; - - // check the prefix guard band - for (int i = 0; i < cms_guardBandSize; ++i, ++guard) - if (*guard != cms_guardFillPattern) - { - corrupt = true; - DEBUG_REPORT_LOG_PRINT(true, ("MemoryManager::free corrupted guard prefix at position %3d = %02x\n", i - cms_guardBandSize, static_cast(*guard))); - DEBUG_OUTPUT_CHANNEL("Foundation\\MemoryManager", ("MemoryManager::free corrupted guard prefix at position %3d = %02x\n", i - cms_guardBandSize, static_cast(*guard))); - } - - // advance past the user memory - guard += allocatedBlock->getRequestedSize(); - - // check the suffix guard band - for (int j = 0; j < cms_guardBandSize; ++j, ++guard) - if (*guard != cms_guardFillPattern) - { - corrupt = true; - DEBUG_REPORT_LOG_PRINT(true, ("MemoryManager::free corrupted guard suffix at position %3d = %02x\n", j, static_cast(*guard))); - DEBUG_OUTPUT_CHANNEL("Foundation\\MemoryManager", ("MemoryManager::free corrupted guard suffix at position %3d = %02x\n", j, static_cast(*guard))); - } - - if (corrupt) - { - MemoryManagerNamespace::report(allocatedBlock, false); - ms_criticalSection->leave(); - DEBUG_FATAL(true, ("corrupted guard pattern")); - return; //lint !e527 // Unreachable - } - } -#endif - -#if DO_SCALAR - if (allocatedBlock->isAllocatedAsArray() != array) //lint !e731 // Info -- Boolean argument to equal/not equal - { - MemoryManagerNamespace::report(allocatedBlock, false); - #ifdef _DEBUG - bool const blockArray = allocatedBlock->isAllocatedAsArray(); - ms_criticalSection->leave(); - FATAL(true, ("allocated %s deleted %s", blockArray ? "array" : "scalar", array ? "array" : "scalar")); //lint !e731 // Info -- Boolean argument to equal/not equal - #endif - } -#endif - - int const memorySize = allocatedBlock->getSize(); - - // wipe the user memory -#if DO_FREE_FILLS - imemset(reinterpret_cast(allocatedBlock) + cms_allocatedBlockSize, cms_freeFillPattern, memorySize - cms_allocatedBlockSize); -#endif - - allocatedBlock->setFree(true); -#if DO_SCALAR - allocatedBlock->setAllocatedAsArray(false); -#endif - - // clear out the block records -#if DO_TRACK - allocatedBlock->fillOwnerWithFreePattern(); -#endif - -#if DO_TRACK || DO_GUARDS - ms_currentBytesRequested -= allocatedBlock->getRequestedSize(); - allocatedBlock->setRequestedSize(0); - DEBUG_FATAL(allocatedBlock->getRequestedSize() != 0, ("bad size")); -#endif - - // update the number of bytes allocated - ++ms_freeCalls; - --ms_allocations; - - DEBUG_FATAL((ms_currentBytesAllocated < static_cast(memorySize)), ("currentBytesAllocated underflow")); - ms_currentBytesAllocated -= memorySize; -#if DO_TRACK - if (!allocatedBlock->checkForLeaks()) - ms_currentBytesAllocatedNoLeakTest -= memorySize; -#endif - DEBUG_FATAL(ms_allocations < 0, ("allocations underflow")); - -// DEBUG_REPORT_LOG(ms_logEachAlloc, ("MemoryManager::free() requested_size=%d, alloc_size=%d, userPointer=%p, allocatedBlock=%p\n", requestedSize, memorySize, userPointer, allocatedBlock)); - - Block *block = allocatedBlock; - - // recombine with the previous block - if (block->getPrevious()->isFree()) - { - FreeBlock * const previous = static_cast(block->getPrevious()); - removeFromFreeList(previous); - previous->setNext(block->getNext()); - block->getNext()->setPrevious(previous); - -#if DO_FREE_FILLS - memset(block, cms_freeFillPattern, cms_freeBlockSize); -#endif - block = previous; - } - - // recombine with the following block - if (block->getNext()->isFree()) - { - FreeBlock * const next = static_cast(block->getNext()); - removeFromFreeList(next); - block->setNext(next->getNext()); - next->getNext()->setPrevious(block); - -#if DO_FREE_FILLS - memset(next, cms_freeFillPattern, cms_freeBlockSize); -#endif - } - - addToFreeList(block); - - ms_criticalSection->leave(); -#endif -} - -// ---------------------------------------------------------------------- - -int MemoryManagerNamespace::quickGuessIsValidPointerFromHeap(void const * userPointer) -{ - int result = 0; - AllocatedBlock const * allocatedBlock = reinterpret_cast(reinterpret_cast(userPointer) - (cms_allocatedBlockSize + cms_guardBandSize)); - - ms_criticalSection->enter(); - if (allocatedBlock->getNext()->getPrevious() != allocatedBlock) result = 1; - if (allocatedBlock->getPrevious()->getNext() != allocatedBlock) result = 2; - if (allocatedBlock->isFree()) result = 3; - ms_criticalSection->leave(); - - return result; -} - -// ---------------------------------------------------------------------- - -int MemoryManagerNamespace::authoritativeIsValidPointerFromHeap(void const * userPointer) -{ - ms_criticalSection->enter(); - - int result = quickGuessIsValidPointerFromHeap(userPointer); - if (result != 0) - return result; - - result = 16; - for (SystemAllocation * systemAllocation = ms_firstSystemAllocation; systemAllocation; systemAllocation = systemAllocation->getNext()) - for (Block * block = systemAllocation->getFirstMemoryBlock()->getNext(); result != 0 && block != systemAllocation->getLastMemoryBlock(); block = block->getNext()) - if (!block->isFree()) - { - byte const * memory = reinterpret_cast(block) + cms_allocatedBlockSize + cms_guardBandSize; - if (memory == userPointer) - result = 0; - } - - ms_criticalSection->leave(); - - return result; -} - -// ---------------------------------------------------------------------- -/** - * Take ownership for a block of memory. - * - * @param userPointer Memory to take ownership of - */ - -void MemoryManager::own(void * userPointer) -{ - UNREF(userPointer); - -#if DISABLED || !DO_TRACK - return; -#else - - DEBUG_FATAL(!ms_installed, ("not installed")); - - if (!userPointer) - return; - - ms_criticalSection->enter(); - - // fetch the block pointer - AllocatedBlock * block = reinterpret_cast(reinterpret_cast(userPointer) - (cms_allocatedBlockSize + cms_guardBandSize)); - DEBUG_FATAL(block->isFree(), ("cannot own a free block")); - - // update the owners - { - enum { OFFSET = 2 }; - uint32 owners[DO_TRACK + OFFSET]; - DebugHelp::getCallStack(owners, DO_TRACK + OFFSET); - - for (int i = 0; i < DO_TRACK; ++i) - block->setOwner(i, owners[i + OFFSET]); - } - - ms_criticalSection->leave(); -#endif -} - -// ---------------------------------------------------------------------- - -void MemoryManager::verify(bool guardPatterns, bool freePatterns) -{ - UNREF(guardPatterns); - UNREF(freePatterns); - -#if DO_FREE_FILLS || DO_GUARDS - - ms_criticalSection->enter(); - - // search for the memory pointer - for (SystemAllocation * systemAllocation = ms_firstSystemAllocation; systemAllocation; systemAllocation = systemAllocation->getNext()) - for (Block * block = systemAllocation->getFirstMemoryBlock()->getNext(); block != systemAllocation->getLastMemoryBlock(); block = block->getNext()) - if (block->isFree()) - { -#if DO_FREE_FILLS - if (freePatterns) - { - bool corrupt = false; - byte * memory = reinterpret_cast(block) + cms_freeBlockSize; - int freeSize = block->getSize() - cms_freeBlockSize; - - for (int i = 0; i < freeSize; ++i, ++memory) - if (*memory != cms_freeFillPattern) - { - corrupt = true; - DEBUG_REPORT_LOG_PRINT(true, ("corrupted free pattern at position %3d [membase=0x%x, memaddr=0x%x] = %02x\n", i, reinterpret_cast(reinterpret_cast(block) + cms_freeBlockSize), reinterpret_cast(reinterpret_cast(block) + cms_freeBlockSize + i), static_cast(*memory))); - DEBUG_OUTPUT_CHANNEL("Foundation\\MemoryManager", ("corrupted free pattern at position %3d = %02x\n", i, static_cast(*memory))); - } - - if (corrupt) - { - ms_criticalSection->leave(); - DEBUG_FATAL(true, ("corrupted free pattern")); - } - } -#endif - } - else - if (guardPatterns) - { -#if DO_GUARDS - // verify the guard bands - byte * guard = reinterpret_cast(block) + cms_allocatedBlockSize; - bool corrupt = false; - - // check the prefix guard band - for (int i = 0; i < cms_guardBandSize; ++i, ++guard) - if (*guard != cms_guardFillPattern) - { - corrupt = true; - DEBUG_REPORT_LOG_PRINT(true, ("corrupted guard prefix at position %3d = %02x\n", i - cms_guardBandSize, static_cast(*guard))); - DEBUG_OUTPUT_CHANNEL("Foundation\\MemoryManager", ("corrupted guard prefix at position %3d = %02x\n", i - cms_guardBandSize, static_cast(*guard))); - } - - // advance past the user memory - guard += static_cast(block)->getRequestedSize(); - - // check the suffix guard band - for (int j = 0; j < cms_guardBandSize; ++j, ++guard) - if (*guard != cms_guardFillPattern) - { - corrupt = true; - DEBUG_REPORT_LOG_PRINT(true, ("corrupted guard suffix at position %3d = %02x\n", j, static_cast(*guard))); - DEBUG_OUTPUT_CHANNEL("Foundation\\MemoryManager", ("corrupted guard suffix at position %3d = %02x\n", j, static_cast(*guard))); - } - - if (corrupt) - { - MemoryManagerNamespace::report(static_cast(block), false); - ms_criticalSection->leave(); - DEBUG_FATAL(true, ("corrupted guard pattern")); - } -#endif - } - - ms_criticalSection->leave(); - -#endif -} - -// ---------------------------------------------------------------------- -/** - * @internal - */ - -void MemoryManagerNamespace::report(AllocatedBlock const * block, bool leak) -{ -#if DO_TRACK - uint32 const owner = block->getOwner(0); -#else - uint32 const owner = 0; -#endif -#if DO_TRACK || DO_GUARDS - int const requestedSize = block->getRequestedSize();; -#else - int const requestedSize = 0; -#endif - - char buffer[256]; - char libName[256]; - char fileName[256]; - int line = 0; - int const memory = reinterpret_cast(reinterpret_cast(block) + cms_allocatedBlockSize + cms_guardBandSize); - - if (ms_allowNameLookup && DebugHelp::lookupAddress(owner, libName, fileName, sizeof(fileName), line)) - { - sprintf(buffer, "%s(%d) : %08X memory %s, %d bytes\n", fileName, line, memory, leak ? "leak" : "allocation", static_cast(requestedSize)); - } - else - { - sprintf(buffer, "unknown(0x%08X) : %08X memory %s, %d bytes\n", static_cast(owner), memory, leak ? "leak" : "allocation", static_cast(requestedSize)); - } - - (*LogMessage)(buffer); - -#if DO_TRACK > 1 - { - for (int i = 1; i < DO_TRACK; ++i) - if (block->getOwner(i)) - { - if (ms_allowNameLookup && DebugHelp::lookupAddress(block->getOwner(i), libName, fileName, sizeof(fileName), line)) - sprintf(buffer, " %s(%d) : caller %d\n", fileName, line, i); - else - sprintf(buffer, " 0x%08X : caller %d\n", static_cast(block->getOwner(i)), i); - (*LogMessage)(buffer); - } - } -#endif -} - -// ---------------------------------------------------------------------- -/** - * Dump information about all outstanding allocations. - */ - -int MemoryManagerNamespace::report(bool leak) -{ - DEBUG_FATAL(!ms_installed, ("not installed")); - - int count = 0; - ms_criticalSection->enter(); - - // search for the memory pointer - for (SystemAllocation * systemAllocation = ms_firstSystemAllocation; systemAllocation; systemAllocation = systemAllocation->getNext()) - for (Block * block = systemAllocation->getFirstMemoryBlock()->getNext(); block != systemAllocation->getLastMemoryBlock(); block = block->getNext()) - if (!block->isFree()) - { -#if DO_TRACK - if (!leak || static_cast(block)->checkForLeaks()) -#else - if (!leak) -#endif - { - report(static_cast(block), leak); - ++count; - } - } - - ms_criticalSection->leave(); - - return count; -} - -// ---------------------------------------------------------------------- -/** - * Dump information about all outstanding allocations. - */ - -void MemoryManager::report() -{ - IGNORE_RETURN(MemoryManagerNamespace::report(false)); -} - -//----------------------------------------------------------------------- - -void MemoryManagerNamespace::logMessageToFd(char const *message) -{ - if (ms_logMessageFd >= 0) - _write(ms_logMessageFd, message, strlen(message)); -} - -//----------------------------------------------------------------------- - -bool MemoryManagerNamespace::reportToFile(char const *fileName, bool leak) -{ - if (ms_logMessageFd >= 0) - return false; - - ms_logMessageFd = _open(fileName, O_CREAT | O_TRUNC | O_WRONLY, S_IREAD | S_IWRITE); - if (ms_logMessageFd < 0) - return false; - - void (*oldLogMessage)(char const * message) = LogMessage; - LogMessage = &logMessageToFd; - - report(leak); - - LogMessage = oldLogMessage; - - _close(ms_logMessageFd); - ms_logMessageFd = -1; - - return true; -} - -//----------------------------------------------------------------------- - -bool MemoryManager::reportToFile(char const *fileName, bool leak) -{ - return MemoryManagerNamespace::reportToFile(fileName, leak); -} - -// ====================================================================== -// DISABLE_MEMORY_MANAGER -#else -// ====================================================================== -namespace MemoryManagerNamespace -{ - // Memory tracking variables avialble when memory manger is running - // in disabled mode for linux - int ms_allocateCalls; - int ms_freeCalls; - unsigned long ms_allocateBytesTotal; -#ifndef _WIN32 - int ms_processVmSizeKBytes; -#endif - unsigned long ms_maxBytesAllocated; - int ms_allocations; - int ms_maxAllocations; - bool ms_installed; - - struct Statm //cache for /proc/statm data - { - int tpsr; //total program size resident - int rss; //resident set size share - }; - - Statm s_statm; - int s_pagesize; - - RecursiveMutex * ms_criticalSection; -} - -using namespace MemoryManagerNamespace; - -// ---------------------------------------------------------------------- - -MemoryManager::MemoryManager() -{ - // Initialize all memory tracking vars - MemoryManagerNamespace::ms_allocateCalls = 0; - MemoryManagerNamespace::ms_freeCalls = 0; - MemoryManagerNamespace::ms_allocateBytesTotal = 0; -#ifndef _WIN32 - MemoryManagerNamespace::ms_processVmSizeKBytes = 0; -#endif - MemoryManagerNamespace::ms_maxBytesAllocated = 0; - MemoryManagerNamespace::ms_allocations = 0; - MemoryManagerNamespace::ms_maxAllocations= 0; - - DEBUG_FATAL(MemoryManagerNamespace::ms_installed, ("already installed")); - - ms_criticalSection = new RecursiveMutex; - - MemoryManagerNamespace::ms_installed = true; - -#if defined(PLATFORM_WIN32) && defined(_DEBUG) - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW); - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW); - - int crtHeapFlags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - crtHeapFlags |= _CRTDBG_ALLOC_MEM_DF; - //crtHeapFlags |= _CRTDBG_CHECK_ALWAYS_DF; - crtHeapFlags |= _CRTDBG_LEAK_CHECK_DF; - _CrtSetDbgFlag(crtHeapFlags); -#endif -} - -// ---------------------------------------------------------------------- - -MemoryManager::~MemoryManager() -{ - delete ms_criticalSection; -} - -// ---------------------------------------------------------------------- - -void MemoryManager::verify(bool, bool) -{ -#if defined(PLATFORM_WIN32) && defined(_DEBUG) - const int result = _CrtCheckMemory(); - FATAL(result==FALSE, ("Heap corruption detected!\n")); -#endif -} - -// ---------------------------------------------------------------------- - -unsigned long MemoryManager::getCurrentNumberOfBytesAllocated(const int processId) -{ - -#ifdef _WIN32 - UNREF(processId); - return 0; -#else - - static char filename[30]; - static FILE *inStatmFile; - static time_t seconds = 0; - - unsigned long retVal = 0; - -#if !DISABLED - ms_criticalSection->enter(); -#endif - - if (processId) - { - if ((time (0) - seconds) > 60 ) - { - if (seconds == 0) - { - snprintf(filename, sizeof(filename)-1, "/proc/%d/statm", processId); - filename[sizeof(filename)-1] = '\0'; - s_pagesize = getpagesize(); - } - - seconds = time (0); - - inStatmFile = fopen(filename,"rt"); - - if (inStatmFile) - { - if (fscanf (inStatmFile, "%d %d", &s_statm.tpsr, &s_statm.rss) == 2) - { - retVal = static_cast(s_statm.tpsr) * static_cast(s_pagesize); - } - else - { - retVal = 0; - } - fclose(inStatmFile); - } - else - { - retVal = 0; - } - } - else - { - retVal = static_cast(s_statm.tpsr) * static_cast(s_pagesize); - } - } - -#if !DISABLED - ms_criticalSection->leave(); -#endif - - return retVal; -#endif -} - -// ---------------------------------------------------------------------- - -unsigned long MemoryManager::getCurrentNumberOfBytesAllocatedNoLeakTest() -{ - return 0; -} - -// ---------------------------------------------------------------------- - -unsigned long MemoryManager::getMaximumNumberOfBytesAllocated() -{ -#ifdef _WIN32 - return 0; -#else - return MemoryManagerNamespace::ms_maxBytesAllocated; -#endif -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getSystemMemoryAllocatedMegabytes() -{ - return 0; -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getCurrentNumberOfAllocations() -{ -#ifdef _WIN32 - return 0; -#else - return MemoryManagerNamespace::ms_allocations; -#endif -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getMaximumNumberOfAllocations() -{ -#ifdef _WIN32 - return 0; -#else - return MemoryManagerNamespace::ms_maxAllocations; -#endif -} - -// ---------------------------------------------------------------------- - -void MemoryManager::setLimit(int, bool, bool) -{ -} - -// ---------------------------------------------------------------------- - -int MemoryManager::getLimit() -{ - return 3072; -} - -// ---------------------------------------------------------------------- - -void MemoryManager::own(void * userPointer) -{ - UNREF(userPointer); -// __asm int 3; -} - -// ---------------------------------------------------------------------- - -void MemoryManager::setReportAllocations(bool) -{ -} - -// ---------------------------------------------------------------------- - -void MemoryManager::registerDebugFlags() -{ -} - -// ---------------------------------------------------------------------- - -void MemoryManager::report() -{ -} - -// ---------------------------------------------------------------------- - -void * MemoryManager::allocate(size_t size, uint32, bool, bool) -{ -#ifdef _WIN32 - return _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__); - //return (void *)LocalAlloc(LMEM_FIXED, size); -#else - return ::malloc(size); -#endif -} - -// ---------------------------------------------------------------------- - -void MemoryManager::free(void * userPointer, bool) -{ -#ifdef _WIN32 - _free_dbg(userPointer, _NORMAL_BLOCK); - //LocalFree((HLOCAL)userPointer); -#else - ::free(userPointer); - -#endif -} - -// ---------------------------------------------------------------------- - -void *MemoryManager::reallocate(void *userPointer, size_t newSize) -{ -#ifdef _WIN32 - return _realloc_dbg(userPointer, newSize, _NORMAL_BLOCK, __FILE__, __LINE__); - //return (void *)LocalReAlloc((HLOCAL)userPointer, newSize, 0); -#else - return ::realloc(userPointer, newSize); -#endif -} - -// ---------------------------------------------------------------------- - -void MemoryManager::debugReport(void) -{ - -} - -// ---------------------------------------------------------------------- - -void MemoryManager::debugReportMap(void) -{ - -} -#endif - -// ---------------------------------------------------------------------- -// this function is available regardless of the DISABLE_MEMORY_MANAGER setting - -#ifndef _WIN32 -int MemoryManager::getProcessVmSizeKBytes(const int processId) -{ - static char filename[30]; - static FILE *inStatusFile; - static char buffer[128]; - static time_t seconds = 0; - - ms_criticalSection->enter(); - - if (processId) - { - if ((time (0) - seconds) > 60) - { - MemoryManagerNamespace::ms_processVmSizeKBytes = 0; - - if (seconds == 0) - { - snprintf(filename, sizeof(filename)-1, "/proc/%d/status", processId); - filename[sizeof(filename)-1] = '\0'; - } - - seconds = time(0); - - inStatusFile = fopen(filename,"rt"); - - if (inStatusFile) - { - int temp; - - while (fgets(buffer, sizeof(buffer), inStatusFile)) - { - if (1 == sscanf(buffer, "VmSize: %d", &temp)) - { - MemoryManagerNamespace::ms_processVmSizeKBytes = temp; - break; - } - } - - fclose(inStatusFile); - } - } - } - - ms_criticalSection->leave(); - - return MemoryManagerNamespace::ms_processVmSizeKBytes; -} -#endif - -// ====================================================================== diff --git a/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.h b/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.h deleted file mode 100755 index 0f170c55..00000000 --- a/engine/shared/library/sharedMemoryManager/src/shared/MemoryManager.h +++ /dev/null @@ -1,84 +0,0 @@ -// ====================================================================== -// -// MemoryManager.h -// Portions copyright 1998 Bootprint Entertainment -// Portions copyright 2002 Sony Online Entertainment -// All Rights Reserved -// -// ====================================================================== - -#ifndef INCLUDED_MemoryManager_H -#define INCLUDED_MemoryManager_H - -// ====================================================================== - -#include "sharedDebug/DebugHelp.h" - -// ====================================================================== - -#include -#include "sharedMemoryManager/OsNewDel.h" - -// ====================================================================== -// Memory manager class. -// -// This class API is multi-thread safe. -// -// This class provides extensive debugging features for applications, including -// overwrite guard bands, initialize pattern fills, free pattern fills, and -// memory tracking. - -class MemoryManager -{ -public: - - MemoryManager(); - ~MemoryManager(); - - static void setLimit(int megabytes, bool hardLimit, bool preallocate); - static int getLimit(); - static bool isHardLimit(); - - static void registerDebugFlags(); - static void debugReport(); - static void debugReportMap(); - static bool reportToFile(const char * fileName, bool leak); - - static int getCurrentNumberOfAllocations(); - static unsigned long getCurrentNumberOfBytesAllocated(const int processId = 0); - static unsigned long getCurrentNumberOfBytesAllocatedNoLeakTest(); - static int getMaximumNumberOfAllocations(); - static unsigned long getMaximumNumberOfBytesAllocated(); - static int getSystemMemoryAllocatedMegabytes(); - -#ifndef _WIN32 - static int getProcessVmSizeKBytes(const int processId = 0); -#endif - - static DLLEXPORT void *allocate(size_t size, uint32 owner, bool array, bool leakTest); - static DLLEXPORT void free(void *pointer, bool array); - static DLLEXPORT void own(void *pointer); - static void * reallocate(void *userPointer, size_t newSize); - - static void verify(bool guardPatterns, bool freePatterns); - static void setReportAllocations(bool reportAllocations); - static void report(); - -private: - - // disabled - MemoryManager(MemoryManager const &); - MemoryManager &operator =(MemoryManager const &); -}; - -// ====================================================================== - -#ifdef _DEBUG - #define MEM_OWN(a) MemoryManager::own(a) -#else - #define MEM_OWN(a) UNREF(a) -#endif - -// ====================================================================== - -#endif diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp b/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp deleted file mode 100755 index a6ad6331..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// ====================================================================== -// -// OsMemory.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/OsMemory.h" - -// ====================================================================== - -void OsMemory::install() -{ -} - -// ---------------------------------------------------------------------- - -void OsMemory::remove() -{ -} - -// ---------------------------------------------------------------------- - -void *OsMemory::reserve(size_t bytes) -{ - return VirtualAlloc(0, bytes, MEM_RESERVE, PAGE_READWRITE); -} - -// ---------------------------------------------------------------------- - -void *OsMemory::commit(void *addr, size_t bytes) -{ - return VirtualAlloc(addr, bytes, MEM_COMMIT, PAGE_READWRITE); -} - -// ---------------------------------------------------------------------- - -bool OsMemory::free(void *addr, size_t bytes) -{ - UNREF(bytes); - return VirtualFree(addr, 0, MEM_RELEASE) ? true : false; -} - -// ---------------------------------------------------------------------- - -bool OsMemory::protect(void *addr, size_t bytes, bool allowAccess) -{ - DWORD old; - BOOL result = VirtualProtect(addr, bytes, allowAccess ? PAGE_READWRITE : PAGE_NOACCESS, &old); - return result ? true : false; -} - -// ====================================================================== - diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h b/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h deleted file mode 100755 index 07ff6918..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsMemory.h +++ /dev/null @@ -1,29 +0,0 @@ -// ====================================================================== -// -// OsMemory.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsMemory_H -#define INCLUDED_OsMemory_H - -// ====================================================================== - -class OsMemory -{ -public: - static void install(); - static void remove(); - - static void * reserve(size_t bytes); - static void * commit(void *addr, size_t bytes); - static bool free(void *addr, size_t bytes); - static bool protect(void *addr, size_t bytes, bool allowAccess); -}; - -// ====================================================================== - -#endif INCLUDED_OsMemory_H - diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp b/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp deleted file mode 100755 index c6569707..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// ====================================================================== -// -// OsNewDel.cpp -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "sharedMemoryManager/OsNewDel.h" - -// ====================================================================== - -// this is here because MSVC won't call MemoryManager::allocate() from asm directly -static void * __cdecl localAllocate(size_t size, uint32 owner, bool array, bool leakTest) -{ - return MemoryManager::allocate(size, owner, array, leakTest); -} - -// ---------------------------------------------------------------------- - -// We are using the arguments (except for file and line), but MSVC can't tell that. -#pragma warning(disable: 4100) - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new(size_t size, MemoryManagerNotALeak) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, false) - push 0 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new(size_t size) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, true) - push 1 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new[](size_t size) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], true, true) - push 1 - push 1 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new(size_t size, const char *file, int line) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], false, true) - push 1 - push 0 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -__declspec(naked) void *operator new[](size_t size, const char *file, int line) -{ - _asm - { - // setup local call stack - push ebp - mov ebp, esp - - // MemoryManager::alloc(size, [return address], true, true) - push 1 - push 1 - mov eax, dword ptr [ebp+4] - push eax - mov eax, dword ptr [ebp+8] - push eax - call localAllocate - add esp, 12 - - mov esp, ebp - pop ebp - ret - } -} - -// ---------------------------------------------------------------------- - -#pragma warning(default: 4100) - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer) -{ - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer) -{ - if (pointer) - MemoryManager::free(pointer, true); -} - -// ---------------------------------------------------------------------- - -void operator delete(void *pointer, const char *file, int line) -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, false); -} - -// ---------------------------------------------------------------------- - -void operator delete[](void *pointer, const char *file, int line) -{ - UNREF(file); - UNREF(line); - - if (pointer) - MemoryManager::free(pointer, true); -} - -// ====================================================================== -// WARNING!!!!!!! -// -// The init_seg pragma command is used to create certain static objects first, before other static objects are created. -// However, multiple static variables that use the same init_seg category(i.e. compiler) are not guaranteed to destroy in any -// particular order. It is completely random based on how all the linking of static objects occurs. Since this command is being -// used on our memory manager(to overwrite new/delete) - NO OTHER STATIC SHOULD EVER USE INIT_SEG(COMPILER)!!!! This static object -// *MUST* be the final static object that is destroyed. -// -#pragma warning(disable: 4074) -#pragma init_seg(compiler) // ^-Read warning above.-^ -static MemoryManager memoryManager; - -// ====================================================================== - diff --git a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h b/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h deleted file mode 100755 index 477a6674..00000000 --- a/engine/shared/library/sharedMemoryManager/src/win32/OsNewDel.h +++ /dev/null @@ -1,52 +0,0 @@ -// ====================================================================== -// -// OsNewDel.h -// -// Copyright 2002 Sony Online Entertainment -// -// ====================================================================== - -#ifndef INCLUDED_OsNewDel_H -#define INCLUDED_OsNewDel_H - -// ====================================================================== - -enum MemoryManagerNotALeak -{ - MM_notALeak -}; - -void * __cdecl operator new(size_t size, MemoryManagerNotALeak); -void * __cdecl operator new(size_t size); -void * __cdecl operator new[](size_t size); -void * __cdecl operator new(size_t size, char const *file, int line); -void * __cdecl operator new[](size_t size, char const *file, int line); -void * __cdecl operator new(size_t size, void *placement); - -void operator delete(void *pointer); -void operator delete[](void *pointer); -void operator delete(void *pointer, char const *file, int line); -void operator delete[](void *pointer, char const *file, int line); -void operator delete(void *pointer, void *placement); - -#ifndef __PLACEMENT_NEW_INLINE -#define __PLACEMENT_NEW_INLINE - -inline void *operator new(size_t size, void *placement) -{ - static_cast(size); - return placement; -} - -inline void operator delete(void *pointer, void *placement) -{ - static_cast(pointer); - static_cast(placement); -} - -#endif // __PLACEMENT_NEW_INLINE - -// ====================================================================== - -#endif INCLUDED_OsNewDel_H - diff --git a/engine/shared/library/sharedMessageDispatch/src/CMakeLists.txt b/engine/shared/library/sharedMessageDispatch/src/CMakeLists.txt index f22167a8..f7cff858 100644 --- a/engine/shared/library/sharedMessageDispatch/src/CMakeLists.txt +++ b/engine/shared/library/sharedMessageDispatch/src/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ) add_library(sharedMessageDispatch STATIC diff --git a/engine/shared/library/sharedNetwork/src/CMakeLists.txt b/engine/shared/library/sharedNetwork/src/CMakeLists.txt index 11def0eb..aa610ddc 100644 --- a/engine/shared/library/sharedNetwork/src/CMakeLists.txt +++ b/engine/shared/library/sharedNetwork/src/CMakeLists.txt @@ -79,7 +79,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public diff --git a/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h b/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h index 2408bc7b..195cffb3 100755 --- a/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h +++ b/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h @@ -13,7 +13,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include diff --git a/engine/shared/library/sharedNetworkMessages/src/CMakeLists.txt b/engine/shared/library/sharedNetworkMessages/src/CMakeLists.txt index eed44696..e0dd5149 100644 --- a/engine/shared/library/sharedNetworkMessages/src/CMakeLists.txt +++ b/engine/shared/library/sharedNetworkMessages/src/CMakeLists.txt @@ -712,7 +712,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public diff --git a/engine/shared/library/sharedObject/src/CMakeLists.txt b/engine/shared/library/sharedObject/src/CMakeLists.txt index 0f79c8e3..30f228bf 100644 --- a/engine/shared/library/sharedObject/src/CMakeLists.txt +++ b/engine/shared/library/sharedObject/src/CMakeLists.txt @@ -177,7 +177,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedPathfinding/include/public diff --git a/engine/shared/library/sharedPathfinding/src/CMakeLists.txt b/engine/shared/library/sharedPathfinding/src/CMakeLists.txt index 42accf79..a697f343 100644 --- a/engine/shared/library/sharedPathfinding/src/CMakeLists.txt +++ b/engine/shared/library/sharedPathfinding/src/CMakeLists.txt @@ -44,7 +44,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include ) diff --git a/engine/shared/library/sharedRandom/src/CMakeLists.txt b/engine/shared/library/sharedRandom/src/CMakeLists.txt index 3be31afe..7f594aad 100644 --- a/engine/shared/library/sharedRandom/src/CMakeLists.txt +++ b/engine/shared/library/sharedRandom/src/CMakeLists.txt @@ -27,7 +27,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ) add_library(sharedRandom STATIC diff --git a/engine/shared/library/sharedRegex/src/CMakeLists.txt b/engine/shared/library/sharedRegex/src/CMakeLists.txt index 96de2861..27b473d1 100644 --- a/engine/shared/library/sharedRegex/src/CMakeLists.txt +++ b/engine/shared/library/sharedRegex/src/CMakeLists.txt @@ -29,7 +29,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${PCRE_INCLUDE_DIR} ) diff --git a/engine/shared/library/sharedRemoteDebugServer/src/CMakeLists.txt b/engine/shared/library/sharedRemoteDebugServer/src/CMakeLists.txt index fc03f40a..e420e4d8 100644 --- a/engine/shared/library/sharedRemoteDebugServer/src/CMakeLists.txt +++ b/engine/shared/library/sharedRemoteDebugServer/src/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories( #${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public #${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include diff --git a/engine/shared/library/sharedSkillSystem/src/CMakeLists.txt b/engine/shared/library/sharedSkillSystem/src/CMakeLists.txt index 76719fdc..507e2196 100644 --- a/engine/shared/library/sharedSkillSystem/src/CMakeLists.txt +++ b/engine/shared/library/sharedSkillSystem/src/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include diff --git a/engine/shared/library/sharedSynchronization/src/CMakeLists.txt b/engine/shared/library/sharedSynchronization/src/CMakeLists.txt index 82434175..6e7dd03b 100644 --- a/engine/shared/library/sharedSynchronization/src/CMakeLists.txt +++ b/engine/shared/library/sharedSynchronization/src/CMakeLists.txt @@ -49,7 +49,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ) add_library(sharedSynchronization STATIC diff --git a/engine/shared/library/sharedTemplate/src/CMakeLists.txt b/engine/shared/library/sharedTemplate/src/CMakeLists.txt index 075e9766..63992d6a 100644 --- a/engine/shared/library/sharedTemplate/src/CMakeLists.txt +++ b/engine/shared/library/sharedTemplate/src/CMakeLists.txt @@ -154,7 +154,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedTemplateDefinition/include/public diff --git a/engine/shared/library/sharedTemplateDefinition/src/CMakeLists.txt b/engine/shared/library/sharedTemplateDefinition/src/CMakeLists.txt index a25ca0e5..c0a698fa 100644 --- a/engine/shared/library/sharedTemplateDefinition/src/CMakeLists.txt +++ b/engine/shared/library/sharedTemplateDefinition/src/CMakeLists.txt @@ -41,7 +41,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRegex/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public diff --git a/engine/shared/library/sharedTerrain/src/CMakeLists.txt b/engine/shared/library/sharedTerrain/src/CMakeLists.txt index 1989d85a..07e414b9 100644 --- a/engine/shared/library/sharedTerrain/src/CMakeLists.txt +++ b/engine/shared/library/sharedTerrain/src/CMakeLists.txt @@ -128,7 +128,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedImage/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public diff --git a/engine/shared/library/sharedThread/src/CMakeLists.txt b/engine/shared/library/sharedThread/src/CMakeLists.txt index a729633f..e0e9fb4c 100644 --- a/engine/shared/library/sharedThread/src/CMakeLists.txt +++ b/engine/shared/library/sharedThread/src/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedSynchronization/include/public ) diff --git a/engine/shared/library/sharedUtility/src/CMakeLists.txt b/engine/shared/library/sharedUtility/src/CMakeLists.txt index 85fbddb3..592ec70b 100644 --- a/engine/shared/library/sharedUtility/src/CMakeLists.txt +++ b/engine/shared/library/sharedUtility/src/CMakeLists.txt @@ -116,7 +116,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedXml/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include diff --git a/engine/shared/library/sharedXml/src/CMakeLists.txt b/engine/shared/library/sharedXml/src/CMakeLists.txt index 780a4055..4f5f4210 100644 --- a/engine/shared/library/sharedXml/src/CMakeLists.txt +++ b/engine/shared/library/sharedXml/src/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public ${ICONV_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} diff --git a/game/server/application/SwgDatabaseServer/src/CMakeLists.txt b/game/server/application/SwgDatabaseServer/src/CMakeLists.txt index b1277e1d..776d387f 100644 --- a/game/server/application/SwgDatabaseServer/src/CMakeLists.txt +++ b/game/server/application/SwgDatabaseServer/src/CMakeLists.txt @@ -165,7 +165,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -315,7 +315,7 @@ target_link_libraries(SwgDatabaseServer sharedGame sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp index 2784757b..49bcd5c6 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp @@ -63,7 +63,7 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std:: break; } - IndexKey key(row->object_id.getValue(), row->name_id.getValue()); + IndexKey key = { row->object_id.getValue(), row->name_id.getValue() }; ObjvarValue value; value.m_type=row->type.getValue(); @@ -100,7 +100,7 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std:: break; } - IndexKey key(row->object_id.getValue(), row->name_id.getValue()); + IndexKey key = { row->object_id.getValue(), row->name_id.getValue() }; ObjvarValue value; value.m_type=row->type.getValue(); @@ -204,7 +204,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vectorfirst.m_objectId==objectId); ++i) + for (DataType::const_iterator i= m_data.lower_bound(IndexKey {objectId,0}); (i!=m_data.end()) && (i->first.m_objectId==objectId); ++i) { std::string name; bool foundName = false; @@ -234,7 +234,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vectorfirst.m_objectId==objectId); ++i) + for (DataType::const_iterator i= m_overrides.lower_bound(IndexKey {objectId,0}); (i!=m_overrides.end()) && (i->first.m_objectId==objectId); ++i) { std::string name; bool foundName = false; @@ -279,10 +279,10 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vectorkey); - DataType::iterator row=m_data.find(IndexKey(objectId, nameId)); + DataType::iterator row=m_data.find(IndexKey {objectId, nameId}); if (row==m_data.end()) { - row=m_data.insert(std::make_pair(IndexKey(objectId, nameId),ObjvarValue())).first; + row=m_data.insert(std::make_pair(IndexKey{objectId, nameId},ObjvarValue())).first; if (i->cmd==DynamicVariableList::MapType::Command::ADD || override) row->second.m_inDatabase=false; // new variable else @@ -300,12 +300,12 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vectorkey); if (nameId != 0) // It's possible to get an ERASE for a packed objvar where the name was never used in the OBJECT_VARIABLES table. We can safely ignore these. { - DataType::iterator row=m_data.find(IndexKey(objectId, nameId)); + DataType::iterator row=m_data.find(IndexKey {objectId, nameId}); if (row==m_data.end()) { if (i->value.getPosition() == -1 || override) { - row=m_data.insert(std::make_pair(IndexKey(objectId, nameId),ObjvarValue())).first; + row=m_data.insert(std::make_pair(IndexKey {objectId, nameId},ObjvarValue())).first; row->second.m_inDatabase=true; // deleting existing variable } // else it was a packed objvar, and no update is necessary @@ -329,13 +329,10 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vectorfirst.m_objectId==object) { - DataType::iterator next=i; - ++next; - m_data.erase(i); - i=next; + i = m_data.erase(i); } } diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h index f834649b..42bc45ea 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h @@ -57,13 +57,9 @@ public: private: struct IndexKey { - NetworkId m_objectId; + const NetworkId &m_objectId; int m_nameId; - IndexKey(const NetworkId &objectId, int nameId); - ~IndexKey(){ - m_nameId = 0; - } bool operator==(const IndexKey &rhs) const; bool operator<(const IndexKey &rhs) const; }; @@ -74,12 +70,6 @@ public: std::string m_value; bool m_detached; bool m_inDatabase; - ~ObjvarValue(){ - m_type = 0; - m_detached = 0; - m_inDatabase = 0; - m_value.clear(); - } }; typedef std::map DataType; @@ -92,7 +82,6 @@ public: // typedef std::map > LoadIndexType; // LoadIndexType m_loadIndex; - private: ObjvarBuffer(); //disable ObjvarBuffer(const ObjvarBuffer&); //disable @@ -101,14 +90,6 @@ public: // ====================================================================== -inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId &objectId, int nameId) : - m_objectId(objectId), - m_nameId(nameId) -{ -} - -// ---------------------------------------------------------------------- - inline bool ObjvarBuffer::IndexKey::operator==(const IndexKey &rhs) const { return ((m_objectId == rhs.m_objectId) && (m_nameId == rhs.m_nameId)); diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/FirstSwgDatabaseServer.h b/game/server/application/SwgDatabaseServer/src/shared/core/FirstSwgDatabaseServer.h index 00bb7175..d1e4c413 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/FirstSwgDatabaseServer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/core/FirstSwgDatabaseServer.h @@ -12,7 +12,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "sharedFoundation/NetworkIdArchive.h" diff --git a/game/server/application/SwgGameServer/src/CMakeLists.txt b/game/server/application/SwgGameServer/src/CMakeLists.txt index 2971522e..8b7318ef 100644 --- a/game/server/application/SwgGameServer/src/CMakeLists.txt +++ b/game/server/application/SwgGameServer/src/CMakeLists.txt @@ -70,7 +70,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -119,7 +119,7 @@ target_link_libraries(SwgGameServer sharedImage sharedLog sharedMath - sharedMemoryManager + sharedMessageDispatch sharedNetwork sharedNetworkMessages diff --git a/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h b/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h index 967cf170..5ec550fb 100755 --- a/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h +++ b/game/server/application/SwgGameServer/src/shared/core/FirstSwgGameServer.h @@ -13,7 +13,7 @@ #pragma warning ( disable : 4503 ) // name truncated (STL) #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "StringId.h" diff --git a/game/server/library/swgServerNetworkMessages/src/CMakeLists.txt b/game/server/library/swgServerNetworkMessages/src/CMakeLists.txt index f2b60117..0aa25a48 100644 --- a/game/server/library/swgServerNetworkMessages/src/CMakeLists.txt +++ b/game/server/library/swgServerNetworkMessages/src/CMakeLists.txt @@ -54,7 +54,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public diff --git a/game/server/library/swgServerNetworkMessages/src/shared/core/FirstSwgServerNetworkMessages.h b/game/server/library/swgServerNetworkMessages/src/shared/core/FirstSwgServerNetworkMessages.h index dbddd38b..c466b1ab 100755 --- a/game/server/library/swgServerNetworkMessages/src/shared/core/FirstSwgServerNetworkMessages.h +++ b/game/server/library/swgServerNetworkMessages/src/shared/core/FirstSwgServerNetworkMessages.h @@ -13,7 +13,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "sharedNetworkMessages/GameNetworkMessage.h" #include "Archive/AutoDeltaByteStream.h" #include "sharedFoundation/NetworkId.h" diff --git a/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt b/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt index afb2e6bb..86d9fb54 100644 --- a/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt +++ b/game/shared/library/swgSharedNetworkMessages/src/CMakeLists.txt @@ -42,7 +42,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public diff --git a/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h b/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h index 5c94cd82..ca191775 100755 --- a/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h +++ b/game/shared/library/swgSharedNetworkMessages/src/shared/core/FirstSwgSharedNetworkMessages.h @@ -13,7 +13,7 @@ #include "sharedFoundation/FirstSharedFoundation.h" #include "sharedDebug/FirstSharedDebug.h" -#include "sharedMemoryManager/FirstSharedMemoryManager.h" + #include "sharedNetworkMessages/GameNetworkMessage.h" #include "Archive/AutoDeltaByteStream.h" #include "sharedFoundation/NetworkId.h" diff --git a/game/shared/library/swgSharedUtility/src/CMakeLists.txt b/game/shared/library/swgSharedUtility/src/CMakeLists.txt index 9d37ae90..f45c2ffa 100644 --- a/game/shared/library/swgSharedUtility/src/CMakeLists.txt +++ b/game/shared/library/swgSharedUtility/src/CMakeLists.txt @@ -38,7 +38,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public - ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include From 9d8b7c0d3a79ff9764ac98c00272d43bcb2291f3 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 1 Dec 2016 17:57:46 +0000 Subject: [PATCH 03/13] Support oracle 10.2.0.4 client libs --- cmake/linux/FindOracle.cmake | 6 ++++++ .../src/shared/TaskSaveSnapshot.cpp | 4 ++-- .../src/shared/buffers/ObjvarBuffer.cpp | 18 +++++++++--------- .../src/shared/buffers/ObjvarBuffer.h | 12 +++++++++++- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/cmake/linux/FindOracle.cmake b/cmake/linux/FindOracle.cmake index 1fe3dc03..ddc278fc 100644 --- a/cmake/linux/FindOracle.cmake +++ b/cmake/linux/FindOracle.cmake @@ -40,6 +40,12 @@ if(DEFINED ENV{ORACLE_HOME}) /usr/share/oracle/12.1/client64 /usr/lib/oracle/12.1/client /usr/share/oracle/12.1/client + /usr/include/oracle/10.2.0.4/client64 + /usr/include/oracle/10.2.0.4/client + /usr/lib/oracle/10.2.0.4/client64 + /usr/share/oracle/10.2.0.4/client64 + /usr/lib/oracle/10.2.0.4/client + /usr/share/oracle/10.2.0.4/client ${ORACLE_HOME}/rdbms/public ${ORACLE_HOME}/include ${ORACLE_HOME}/sdk/include # Oracle SDK diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp index 982de1ef..8eb2c054 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp @@ -31,8 +31,8 @@ void TaskSaveSnapshot::onComplete() m_snapshot->saveCompleted(); Persister::getInstance().saveCompleted(m_snapshot); - delete m_snapshot; - m_snapshot = nullptr; +// delete m_snapshot; +// m_snapshot = nullptr; } // ====================================================================== diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp index 49bcd5c6..c0e0a5bf 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp @@ -63,7 +63,7 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std:: break; } - IndexKey key = { row->object_id.getValue(), row->name_id.getValue() }; + IndexKey key(row->object_id.getValue(), row->name_id.getValue()); ObjvarValue value; value.m_type=row->type.getValue(); @@ -100,7 +100,7 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std:: break; } - IndexKey key = { row->object_id.getValue(), row->name_id.getValue() }; + IndexKey key(row->object_id.getValue(), row->name_id.getValue()); ObjvarValue value; value.m_type=row->type.getValue(); @@ -204,7 +204,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vectorfirst.m_objectId==objectId); ++i) + for (DataType::const_iterator i= m_data.lower_bound(IndexKey(objectId,0)); (i!=m_data.end()) && (i->first.m_objectId==objectId); ++i) { std::string name; bool foundName = false; @@ -234,7 +234,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vectorfirst.m_objectId==objectId); ++i) + for (DataType::const_iterator i= m_overrides.lower_bound(IndexKey(objectId,0)); (i!=m_overrides.end()) && (i->first.m_objectId==objectId); ++i) { std::string name; bool foundName = false; @@ -279,10 +279,10 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vectorkey); - DataType::iterator row=m_data.find(IndexKey {objectId, nameId}); + DataType::iterator row=m_data.find(IndexKey(objectId, nameId)); if (row==m_data.end()) { - row=m_data.insert(std::make_pair(IndexKey{objectId, nameId},ObjvarValue())).first; + row=m_data.insert(std::make_pair(IndexKey(objectId, nameId),ObjvarValue())).first; if (i->cmd==DynamicVariableList::MapType::Command::ADD || override) row->second.m_inDatabase=false; // new variable else @@ -300,12 +300,12 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vectorkey); if (nameId != 0) // It's possible to get an ERASE for a packed objvar where the name was never used in the OBJECT_VARIABLES table. We can safely ignore these. { - DataType::iterator row=m_data.find(IndexKey {objectId, nameId}); + DataType::iterator row=m_data.find(IndexKey(objectId, nameId)); if (row==m_data.end()) { if (i->value.getPosition() == -1 || override) { - row=m_data.insert(std::make_pair(IndexKey {objectId, nameId},ObjvarValue())).first; + row=m_data.insert(std::make_pair(IndexKey(objectId, nameId),ObjvarValue())).first; row->second.m_inDatabase=true; // deleting existing variable } // else it was a packed objvar, and no update is necessary @@ -329,7 +329,7 @@ void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vectorfirst.m_objectId==object) { i = m_data.erase(i); diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h index 42bc45ea..1d14df7d 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h @@ -57,9 +57,10 @@ public: private: struct IndexKey { - const NetworkId &m_objectId; + NetworkId m_objectId; int m_nameId; + IndexKey(const NetworkId &objectId, int nameId); bool operator==(const IndexKey &rhs) const; bool operator<(const IndexKey &rhs) const; }; @@ -82,6 +83,7 @@ public: // typedef std::map > LoadIndexType; // LoadIndexType m_loadIndex; + private: ObjvarBuffer(); //disable ObjvarBuffer(const ObjvarBuffer&); //disable @@ -90,6 +92,14 @@ public: // ====================================================================== +inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId &objectId, int nameId) : + m_objectId(objectId), + m_nameId(nameId) +{ +} + +// ---------------------------------------------------------------------- + inline bool ObjvarBuffer::IndexKey::operator==(const IndexKey &rhs) const { return ((m_objectId == rhs.m_objectId) && (m_nameId == rhs.m_nameId)); From 066eac440eb362a32b62e84e51d2c4253e6e3c4f Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 2 Dec 2016 23:49:19 +0000 Subject: [PATCH 04/13] nit picking on unrelated to the leak things... --- .../library/serverDatabase/src/shared/TaskSaveSnapshot.cpp | 3 --- .../library/serverGame/src/shared/object/ServerObject.cpp | 4 +--- .../src/shared/buffers/IndexedNetworkTableBuffer.h | 2 ++ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp index 8eb2c054..2222b250 100755 --- a/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp +++ b/engine/server/library/serverDatabase/src/shared/TaskSaveSnapshot.cpp @@ -30,9 +30,6 @@ void TaskSaveSnapshot::onComplete() { m_snapshot->saveCompleted(); Persister::getInstance().saveCompleted(m_snapshot); - -// delete m_snapshot; -// m_snapshot = nullptr; } // ====================================================================== diff --git a/engine/server/library/serverGame/src/shared/object/ServerObject.cpp b/engine/server/library/serverGame/src/shared/object/ServerObject.cpp index 684f559f..55d68b6f 100755 --- a/engine/server/library/serverGame/src/shared/object/ServerObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/ServerObject.cpp @@ -3235,12 +3235,10 @@ bool ServerObject::persist() ServerObject *parent = static_cast(ContainerInterface::getContainedByObject(*this)); if (parent && !parent->isPersisted()) { - WARNING(true, ("Persisting %s into %s which is not persisted!", getNetworkId().getValueString().c_str(), parent->getNetworkId().getValueString().c_str())); + WARNING(true, ("Persisting %s into %s, which is not persisted!", getNetworkId().getValueString().c_str(), parent->getNetworkId().getValueString().c_str())); } #endif - m_persisted = true; - markChildrenPersisted(); sendCreateAndBaselinesToDatabaseServer(); diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/IndexedNetworkTableBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/IndexedNetworkTableBuffer.h index 65ba2205..43595df7 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/IndexedNetworkTableBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/IndexedNetworkTableBuffer.h @@ -105,6 +105,8 @@ IndexedNetworkTableBuffer::~IndexedNetworkTable ++m_sRowsDeleted; i->second=nullptr; } + + m_rows.clear(); } // ---------------------------------------------------------------------- From 12cf580937d0459c813b37de333ff35a14523e38 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 3 Dec 2016 08:28:21 +0000 Subject: [PATCH 05/13] fix all the warnings --- .../server/application/ChatServer/src/shared/ChatServer.cpp | 6 +++--- .../shared/objectTemplate/ServerTangibleObjectTemplate.cpp | 6 +++--- .../shared/objectTemplate/ServerTangibleObjectTemplate.h | 2 +- .../VChatAPI/utils2.0/utils/Base/serializeStringVector.h | 2 -- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/engine/server/application/ChatServer/src/shared/ChatServer.cpp b/engine/server/application/ChatServer/src/shared/ChatServer.cpp index c8e12a6d..542cc4cf 100755 --- a/engine/server/application/ChatServer/src/shared/ChatServer.cpp +++ b/engine/server/application/ChatServer/src/shared/ChatServer.cpp @@ -100,11 +100,11 @@ namespace ChatServerNamespace if(fullName.find(ConfigChatServer::getClusterName()) == std::string::npos) { - fullName = ConfigChatServer::getClusterName() + '+' + fullName; + fullName = std::string(ConfigChatServer::getClusterName()) + std::string("+") + fullName; } if(fullName.find(ConfigChatServer::getGameCode()) == std::string::npos) { - fullName = ConfigChatServer::getGameCode() + '+' + fullName; + fullName = std::string(ConfigChatServer::getGameCode()) + std::string("+") + fullName; } if(fullName.find("SOE") == std::string::npos) { @@ -122,7 +122,7 @@ namespace ChatServerNamespace std::set s_notSubscribedClients; // Control log output for chat room related methods - bool const s_enableChatRoomLogs = false; + bool const s_enableChatRoomLogs = false; // make configurable? } using namespace ChatServerNamespace; diff --git a/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.cpp b/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.cpp index 23505a15..2b4722d3 100644 --- a/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.cpp +++ b/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.cpp @@ -124,7 +124,7 @@ Object * ServerTangibleObjectTemplate::createObject(void) const } // ServerTangibleObjectTemplate::createObject //@BEGIN TFD -const TriggerVolumeData & ServerTangibleObjectTemplate::getTriggerVolumes(int index) const +const TriggerVolumeData ServerTangibleObjectTemplate::getTriggerVolumes(int index) const { const ServerTangibleObjectTemplate * base = nullptr; if (m_baseData != nullptr) @@ -155,8 +155,8 @@ const TriggerVolumeData & ServerTangibleObjectTemplate::getTriggerVolumes(int in } DEBUG_FATAL(index < 0 || static_cast(index) >= m_triggerVolumes.size(), ("template param index out of range")); - const TriggerVolumeData & value = m_triggerVolumes[index]->getValue(); - return value; + + return m_triggerVolumes[index]->getValue(); } // ServerTangibleObjectTemplate::getTriggerVolumes size_t ServerTangibleObjectTemplate::getTriggerVolumesCount(void) const diff --git a/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.h b/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.h index 30d0e447..73292939 100644 --- a/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.h +++ b/engine/server/library/serverGame/src/shared/objectTemplate/ServerTangibleObjectTemplate.h @@ -87,7 +87,7 @@ public: }; public: - const TriggerVolumeData & getTriggerVolumes(int index) const; + const TriggerVolumeData getTriggerVolumes(int index) const; size_t getTriggerVolumesCount(void) const; CombatSkeleton getCombatSkeleton(bool testData = false) const; int getMaxHitPoints(bool testData = false) const; diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeStringVector.h b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeStringVector.h index efa6c80e..873ad9b4 100644 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeStringVector.h +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/serializeStringVector.h @@ -221,8 +221,6 @@ namespace soe return bytes; } - operator stringVector_t () { return *this; } - //unsigned Read(const unsigned char * stream, unsigned size); //DECLARE_SCRIBE_MEMBERS }; From cbfc88d54b1ce38bebf8a7df542af2bcd45bae6d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 3 Dec 2016 23:52:03 +0000 Subject: [PATCH 06/13] cleanup works and reduces our memory footprint, and error messages --- .../src/shared/ConfigServerDatabase.cpp | 26 +++++++------- .../serverDatabase/src/shared/Persister.cpp | 36 +++---------------- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp b/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp index a6bb553f..b0f0891f 100755 --- a/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp +++ b/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp @@ -34,14 +34,14 @@ void ConfigServerDatabase::install(void) ConfigServerUtility::install(); data = &staticData; - KEY_INT (objvarNameCleanupTime, 0); - KEY_INT (orphanedObjectCleanupTime, 0); - KEY_INT (marketAttributesCleanupTime, 0); - KEY_INT (messagesCleanupTime, 0); - KEY_INT (brokenObjectCleanupTime, 0); - KEY_INT (vendorObjectCleanupTime, 0); + KEY_INT (objvarNameCleanupTime, 60); + KEY_INT (orphanedObjectCleanupTime, 60); + KEY_INT (marketAttributesCleanupTime, 60); + KEY_INT (messagesCleanupTime, 60); + KEY_INT (brokenObjectCleanupTime, 60); + KEY_INT (vendorObjectCleanupTime, 60); KEY_STRING (customSQLFilename,""); - KEY_BOOL (enableFixBadCells, false); + KEY_BOOL (enableFixBadCells, true); KEY_STRING (objectTemplateListUpdateFilename,""); KEY_STRING (DSN,"gameserver"); @@ -56,7 +56,7 @@ void ConfigServerDatabase::install(void) KEY_INT (taskManagerPort, 60001); KEY_INT (expectedDBVersion, 270); KEY_BOOL (correctDBVersionRequired,true); - KEY_INT (saveFrequencyLimit,10); + KEY_INT (saveFrequencyLimit,5); KEY_STRING (schemaOwner, ""); KEY_STRING (goldSchemaOwner, ""); KEY_FLOAT (uniqueMessageCacheTimeSec, 30.0f); @@ -72,10 +72,10 @@ void ConfigServerDatabase::install(void) KEY_BOOL (reportSaveTimes, false); KEY_BOOL (shouldSleep, true); KEY_BOOL (enableLoadLocks, true); - KEY_INT (databaseReconnectTime, 0); + KEY_INT (databaseReconnectTime, 1); KEY_BOOL (logChunkLoading,false); KEY_BOOL (useMemoryManagerForOCI,false); - KEY_INT (maxCharactersPerLoadRequest,10); + KEY_INT (maxCharactersPerLoadRequest,20); KEY_INT (maxChunksPerLoadRequest,200); KEY_FLOAT (maxLoadStartDelay,300.0f); KEY_INT (maxErrorCountBeforeDisconnect,5); @@ -97,7 +97,7 @@ void ConfigServerDatabase::install(void) KEY_BOOL (enableGoldDatabase, false); KEY_STRING (maxGoldNetworkId, "10000000"); KEY_FLOAT (defaultQueueUpdateTimeLimit, 0.25f); - KEY_BOOL (enableDataCleanup, false); + KEY_BOOL (enableDataCleanup, true); KEY_INT (defaultLazyDeleteBulkBindSize, 100); KEY_INT (defaultLazyDeleteSleepTime, 1000); KEY_INT (writeDelay, 0); @@ -106,11 +106,11 @@ void ConfigServerDatabase::install(void) KEY_INT (maxLoaderFinishedTasks, 100); KEY_FLOAT (reportLongFrameTime, 1.0f); KEY_BOOL (enableVerboseMessageLogging, false); - KEY_BOOL (profilerExpandAll, true); + KEY_BOOL (profilerExpandAll, false); KEY_INT (profilerDisplayPercentageMinimum, 0); KEY_BOOL (fatalOnDataError, false); KEY_INT (maxUnackedLoadCount, 1000000000); // by default, set to an "unlimited" number, and use maxUnackedLoadCountPerServer as the cap - KEY_INT (maxUnackedLoadCountPerServer, 2); + KEY_INT (maxUnackedLoadCountPerServer, 5); KEY_INT (auctionLocationLoadBatchSize, 100); KEY_INT (auctionLoadBatchSize, 100); KEY_INT (auctionAttributeLoadBatchSize, 100); diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 30f951c6..736a98e5 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -174,44 +174,15 @@ Persister::~Persister() { DEBUG_FATAL(taskQueue,("Call shutdown() before deleting Persister.\n")); - for (auto i = m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) { + ServerSnapshotMap::iterator i; + for (i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) delete i->second; - i->second = nullptr; - } - - for (auto i = m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) { + for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) delete i->second; - i->second = nullptr; - } - - for (auto i = m_newCharacterSnapshots.begin(); i!=m_newCharacterSnapshots.end(); ++i) { - delete i->second; - i->second = nullptr; - } - - for (auto i = m_objectSnapshotMap.begin(); i!=m_objectSnapshotMap.end(); ++i) { - delete i->second; - i->second = nullptr; - } - - for (auto i = m_savingSnapshots.begin(); i!=m_savingSnapshots.end(); ++i) { - delete *i; - *i = nullptr; - } - - for (auto i = m_savingCharacterSnapshots.begin(); i!=m_savingCharacterSnapshots.end(); ++i) { - delete *i; - *i = nullptr; - } m_currentSnapshots.clear(); m_newObjectSnapshots.clear(); m_objectSnapshotMap.clear(); - - delete m_messageSnapshot; - delete m_commoditiesSnapshot; - delete m_arbitraryGameDataSnapshot; - m_messageSnapshot = nullptr; m_commoditiesSnapshot = nullptr; m_arbitraryGameDataSnapshot = nullptr; @@ -663,6 +634,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } From c254e498bc2079d8f4060d7bf3aa813dc421e02b Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 4 Dec 2016 01:13:01 +0000 Subject: [PATCH 07/13] @cekis, you'll want to toggle this to true for debugging, but it just spams in release mode --- .../library/serverGame/src/shared/core/ConfigServerGame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp b/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp index 7371dbf9..582593d3 100755 --- a/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp +++ b/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp @@ -71,7 +71,7 @@ void ConfigServerGame::install(void) KEY_INT (scriptWatcherInterruptTime, 5000); KEY_INT (scriptStackErrorLimit, 35); KEY_INT (scriptStackErrorLevel, 0); - KEY_BOOL (disableObjvarNullCheck, false); + KEY_BOOL (disableObjvarNullCheck, true); KEY_INT (maxGameServerToSendUniverseData, 1000000); KEY_INT (timeoutToAckUniverseDataReceived, 0); KEY_BOOL (disableCombat, false); From c8b782b0d1e23b4b74d56c48047fdb8271439f34 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 6 Dec 2016 03:07:37 +0000 Subject: [PATCH 08/13] g3 for debug builds --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86432ad7..d93e8e8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ elseif(UNIX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -O0 -g3") # funroll loops and everything else potentially crazy for performance here set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 -Ofast -funroll-loops") From b17393763a82bca26cb20fab517b345349d2c261 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 6 Dec 2016 16:58:56 +0000 Subject: [PATCH 09/13] madness --- .../server/library/serverDatabase/src/shared/Persister.cpp | 7 ++++++- .../SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp | 2 ++ .../SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h | 6 ++---- .../SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp | 4 +++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 736a98e5..a369e6e7 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -602,6 +602,9 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { + delete completedSnapshot; + completedSnapshot = nullptr; + m_savingSnapshots.erase(i, m_savingSnapshots.end()); if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -634,7 +637,9 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); - + delete completedSnapshot; + completedSnapshot = nullptr; + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp index c0e0a5bf..bb2c58f7 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp @@ -38,6 +38,8 @@ ObjvarBuffer::ObjvarBuffer(DB::ModeQuery::Mode mode, ObjectTableBuffer *objectTa ObjvarBuffer::~ObjvarBuffer() { + m_data.clear(); + m_overrides.clear(); } bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std::string &schema, bool usingGoldDatabase) diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h index 1d14df7d..f82adae7 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h @@ -60,7 +60,7 @@ public: NetworkId m_objectId; int m_nameId; - IndexKey(const NetworkId &objectId, int nameId); + IndexKey(const NetworkId objectId, int nameId); bool operator==(const IndexKey &rhs) const; bool operator<(const IndexKey &rhs) const; }; @@ -92,9 +92,7 @@ public: // ====================================================================== -inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId &objectId, int nameId) : - m_objectId(objectId), - m_nameId(nameId) +inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId objectId, int nameId) : m_objectId(objectId), m_nameId(nameId) { } diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp index f81f75ad..ea1b4ee3 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.cpp @@ -139,7 +139,9 @@ SwgSnapshot::SwgSnapshot(DB::ModeQuery::Mode mode, bool useGoldDatabase) : // ---------------------------------------------------------------------- -SwgSnapshot::~SwgSnapshot(){} +SwgSnapshot::~SwgSnapshot(){ + +} // ---------------------------------------------------------------------- From 4a1159ad147d707bec30bc91c9ce29aa26c0a342 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 29 Nov 2016 23:00:36 +0000 Subject: [PATCH 10/13] this builds and runs but our objvars are never loaded (or buffered?) properly --- .../SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp | 4 ++-- .../SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp index bb2c58f7..b3c52b05 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp @@ -199,7 +199,7 @@ bool ObjvarBuffer::save(DB::Session *session) // ---------------------------------------------------------------------- -void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vector &commands) const +void ObjvarBuffer::getObjvarsForObject(const NetworkId objectId, std::vector commands) const { DynamicVariableList::MapType::Command c; @@ -258,7 +258,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vector &commands) +void ObjvarBuffer::updateObjvars(const NetworkId objectId, const std::vector commands) { bool override=false; // flag that we're dealing with the gold data override case (storing an objvar change in the live database, on an object that came from the gold database) if (ConfigServerDatabase::getEnableGoldDatabase() && objectId < ConfigServerDatabase::getMaxGoldNetworkId()) diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h index f82adae7..baedb097 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h @@ -49,10 +49,10 @@ public: virtual bool save(DB::Session *session); virtual void removeObject(const NetworkId &object); - DBSchema::ObjectVariableRow *findRowByIndex(const NetworkId &objectId, const std::string &name); + DBSchema::ObjectVariableRow *findRowByIndex(const NetworkId objectId, const std::string &name); - void updateObjvars(const NetworkId &objectId, const std::vector &commands); - void getObjvarsForObject(const NetworkId &objectId, std::vector &commands) const; + void updateObjvars(const NetworkId objectId, const std::vector commands); + void getObjvarsForObject(const NetworkId objectId, std::vector commands) const; private: struct IndexKey From eab175813df382c8786dfe2db56c30ed38c89e5e Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 8 Dec 2016 10:07:51 +0000 Subject: [PATCH 11/13] remove another unused flag --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d93e8e8a..3f6afb74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ elseif(UNIX) # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") #endif() - add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_USING_STL -D_GNU_SOURCE -D_XOPEN_SOURCE=500) + add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_GNU_SOURCE -D_XOPEN_SOURCE=500) endif() add_subdirectory(external) From a353c128c33c02cf05ccbc956d6ea4ec213cb400 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 8 Dec 2016 17:23:03 +0000 Subject: [PATCH 12/13] fix db bug; cleanup; better destructors --- .../serverDatabase/src/shared/Persister.cpp | 36 ++++++++++++++----- .../src/shared/buffers/ObjvarBuffer.cpp | 30 ++++++++-------- .../src/shared/buffers/ObjvarBuffer.h | 12 +++---- .../src/shared/core/SwgSnapshot.h | 2 +- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index a369e6e7..2d013510 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -174,15 +174,33 @@ Persister::~Persister() { DEBUG_FATAL(taskQueue,("Call shutdown() before deleting Persister.\n")); - ServerSnapshotMap::iterator i; - for (i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) + for (auto i=m_currentSnapshots.begin(); i!=m_currentSnapshots.end(); ++i) { delete i->second; - for (i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) + i->second = nullptr; + } + + for (auto i=m_newObjectSnapshots.begin(); i!=m_newObjectSnapshots.end(); ++i) { delete i->second; + i->second = nullptr; + } + + for (auto i=m_savingCharacterSnapshots.begin(); i!=m_savingCharacterSnapshots.end(); ++i) { + delete *i; + *i = nullptr; + } + + for (auto i=m_savingSnapshots.begin(); i!=m_savingSnapshots.end(); ++i) { + delete *i; + *i = nullptr; + } m_currentSnapshots.clear(); m_newObjectSnapshots.clear(); m_objectSnapshotMap.clear(); + m_savingCharacterSnapshots.clear(); + m_savingSnapshots.clear(); + + m_messageSnapshot = nullptr; m_commoditiesSnapshot = nullptr; m_arbitraryGameDataSnapshot = nullptr; @@ -599,12 +617,14 @@ void Persister::endBaselines(const NetworkId &objectId, uint32 serverId) void Persister::saveCompleted(Snapshot *completedSnapshot) { + if (completedSnapshot) { + delete completedSnapshot; + completedSnapshot = nullptr; + } + SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { - delete completedSnapshot; - completedSnapshot = nullptr; - m_savingSnapshots.erase(i, m_savingSnapshots.end()); if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { @@ -637,10 +657,8 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) { SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); - delete completedSnapshot; - completedSnapshot = nullptr; - m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp index b3c52b05..5fdd99e5 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.cpp @@ -64,16 +64,14 @@ bool ObjvarBuffer::load(DB::Session *session,const DB::TagSet &tags, const std:: { break; } - - IndexKey key(row->object_id.getValue(), row->name_id.getValue()); - ObjvarValue value; - value.m_type=row->type.getValue(); - - // The string is stored in the database as utf8, so a wide-to-narrow is appropriate - value.m_value=Unicode::wideToNarrow(row->value.getValue()); - - value.m_detached=false; + IndexKey key(row->object_id.getValue(), row->name_id.getValue()); + ObjvarValue value; + value.m_type=row->type.getValue(); + + // The string is stored in the database as utf8, so a wide-to-narrow is appropriate + value.m_value=Unicode::wideToNarrow(row->value.getValue()); + m_data.insert(std::make_pair(key,value)); } } @@ -199,7 +197,7 @@ bool ObjvarBuffer::save(DB::Session *session) // ---------------------------------------------------------------------- -void ObjvarBuffer::getObjvarsForObject(const NetworkId objectId, std::vector commands) const +void ObjvarBuffer::getObjvarsForObject(const NetworkId &objectId, std::vector &commands) const { DynamicVariableList::MapType::Command c; @@ -258,7 +256,7 @@ void ObjvarBuffer::getObjvarsForObject(const NetworkId objectId, std::vector commands) +void ObjvarBuffer::updateObjvars(const NetworkId &objectId, const std::vector &commands) { bool override=false; // flag that we're dealing with the gold data override case (storing an objvar change in the live database, on an object that came from the gold database) if (ConfigServerDatabase::getEnableGoldDatabase() && objectId < ConfigServerDatabase::getMaxGoldNetworkId()) @@ -314,8 +312,9 @@ void ObjvarBuffer::updateObjvars(const NetworkId objectId, const std::vectorsecond.m_type = i->value.getType(); - row->second.m_detached = true; + row->second.m_detached = true; //why the fuck even store it at this point? } + break; } @@ -332,9 +331,12 @@ void ObjvarBuffer::updateObjvars(const NetworkId objectId, const std::vectorfirst.m_objectId==object) + while (i!=m_data.end()) { - i = m_data.erase(i); + if (i->first.m_objectId==object) + i = m_data.erase(i); + else + ++i; } } diff --git a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h index baedb097..2ee2f91a 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h +++ b/game/server/application/SwgDatabaseServer/src/shared/buffers/ObjvarBuffer.h @@ -49,18 +49,18 @@ public: virtual bool save(DB::Session *session); virtual void removeObject(const NetworkId &object); - DBSchema::ObjectVariableRow *findRowByIndex(const NetworkId objectId, const std::string &name); + DBSchema::ObjectVariableRow *findRowByIndex(const NetworkId &objectId, const std::string &name); - void updateObjvars(const NetworkId objectId, const std::vector commands); - void getObjvarsForObject(const NetworkId objectId, std::vector commands) const; + void updateObjvars(const NetworkId &objectId, const std::vector &commands); + void getObjvarsForObject(const NetworkId &objectId, std::vector &commands) const; private: struct IndexKey { - NetworkId m_objectId; + const NetworkId m_objectId; int m_nameId; - IndexKey(const NetworkId objectId, int nameId); + IndexKey(const NetworkId &objectId, int nameId); bool operator==(const IndexKey &rhs) const; bool operator<(const IndexKey &rhs) const; }; @@ -92,7 +92,7 @@ public: // ====================================================================== -inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId objectId, int nameId) : m_objectId(objectId), m_nameId(nameId) +inline ObjvarBuffer::IndexKey::IndexKey(const NetworkId &objectId, int nameId) : m_objectId(objectId), m_nameId(nameId) { } diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h index e2494000..73be48c3 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h +++ b/game/server/application/SwgDatabaseServer/src/shared/core/SwgSnapshot.h @@ -119,7 +119,7 @@ public: void newMissionObject (NetworkId const & objectId); void newPlanetObject (NetworkId const & objectId); void newPlayerObject (NetworkId const & objectId); - void newPlayerQuestObject (NetworkId const & objectId); + void newPlayerQuestObject (NetworkId const & objectId); void newRegionCircleObject (NetworkId const & objectId); void newRegionObject (NetworkId const & objectId); void newRegionRectangleObject (NetworkId const & objectId); From 6418f430f9cf72930abb6610c0665f35b13c92da Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 9 Dec 2016 03:37:21 +0000 Subject: [PATCH 13/13] this should let us delete snapshots at the cost of latency --- .../src/shared/ConfigServerDatabase.cpp | 14 +++++----- .../src/shared/DatabaseProcess.cpp | 8 +++--- .../serverDatabase/src/shared/Persister.cpp | 26 +++++++++++++------ .../serverDatabase/src/shared/Persister.h | 6 +++++ .../src/shared/core/SwgDatabaseServer.cpp | 2 -- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp b/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp index b0f0891f..9379508b 100755 --- a/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp +++ b/engine/server/library/serverDatabase/src/shared/ConfigServerDatabase.cpp @@ -34,12 +34,12 @@ void ConfigServerDatabase::install(void) ConfigServerUtility::install(); data = &staticData; - KEY_INT (objvarNameCleanupTime, 60); - KEY_INT (orphanedObjectCleanupTime, 60); - KEY_INT (marketAttributesCleanupTime, 60); - KEY_INT (messagesCleanupTime, 60); - KEY_INT (brokenObjectCleanupTime, 60); - KEY_INT (vendorObjectCleanupTime, 60); + KEY_INT (objvarNameCleanupTime, 10); + KEY_INT (orphanedObjectCleanupTime, 10); + KEY_INT (marketAttributesCleanupTime, 10); + KEY_INT (messagesCleanupTime, 10); + KEY_INT (brokenObjectCleanupTime, 10); + KEY_INT (vendorObjectCleanupTime, 10); KEY_STRING (customSQLFilename,""); KEY_BOOL (enableFixBadCells, true); KEY_STRING (objectTemplateListUpdateFilename,""); @@ -97,7 +97,7 @@ void ConfigServerDatabase::install(void) KEY_BOOL (enableGoldDatabase, false); KEY_STRING (maxGoldNetworkId, "10000000"); KEY_FLOAT (defaultQueueUpdateTimeLimit, 0.25f); - KEY_BOOL (enableDataCleanup, true); + KEY_BOOL (enableDataCleanup, false); KEY_INT (defaultLazyDeleteBulkBindSize, 100); KEY_INT (defaultLazyDeleteSleepTime, 1000); KEY_INT (writeDelay, 0); diff --git a/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp b/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp index f5dcb25c..5b097f2c 100755 --- a/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp +++ b/engine/server/library/serverDatabase/src/shared/DatabaseProcess.cpp @@ -91,13 +91,13 @@ m_queryFetchCount(0) centralServerConnection = new CentralServerConnection(ConfigServerDatabase::getCentralServerAddress(), ConfigServerDatabase::getCentralServerPort()); NetworkSetupData setup; - setup.maxConnections = 100; + setup.maxConnections = 300; setup.port = 0; setup.bindInterface = ConfigServerDatabase::getGameServiceBindInterface(); gameService = new Service(ConnectionAllocator(), setup); NetworkSetupData cmSetup; - cmSetup.maxConnections = 100; + cmSetup.maxConnections = 300; cmSetup.port = ConfigServerDatabase::getCommoditiesServerPort(); cmSetup.bindInterface = ConfigServerDatabase::getCommoditiesServerAddress(); commoditiesService = new Service(ConnectionAllocator(), cmSetup); @@ -128,7 +128,7 @@ m_queryFetchCount(0) DB::Server::setDisconnectSleepTime(ConfigServerDatabase::getDisconnectSleepTime()); DB::Server::setFatalOnDataError(ConfigServerDatabase::getFatalOnDataError()); - // the DatabaseProcess singleton will want to know when major, connection + // the DatabaseProcess singleton will want to know when major, connection // oriented events occur. These events are defined in Game, Task and Central // connection classes. connectToMessage("CentralConnectionOpened"); @@ -252,7 +252,7 @@ void DatabaseProcess::run(void) // TODO: sleep longer if idle if (shouldSleep) { - Os::sleep(1); + Os::sleep(3); } NetworkHandler::dispatch(); diff --git a/engine/server/library/serverDatabase/src/shared/Persister.cpp b/engine/server/library/serverDatabase/src/shared/Persister.cpp index 2d013510..f4fd85b3 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.cpp +++ b/engine/server/library/serverDatabase/src/shared/Persister.cpp @@ -617,15 +617,23 @@ void Persister::endBaselines(const NetworkId &objectId, uint32 serverId) void Persister::saveCompleted(Snapshot *completedSnapshot) { - if (completedSnapshot) { + { + std::lock_guard lck(m_savingDeleting_mtx); + delete completedSnapshot; completedSnapshot = nullptr; } + auto i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); - SnapshotListType::iterator i=std::remove(m_savingSnapshots.begin(),m_savingSnapshots.end(),completedSnapshot); if (i!=m_savingSnapshots.end()) { - m_savingSnapshots.erase(i, m_savingSnapshots.end()); + + { + std::lock_guard lck(m_savingDeleting_mtx); + WARNING(true, ("m_SavingSnapshots is not empty and we're nuking everything for some reason. Is this a leak?")); + m_savingSnapshots.erase(i, m_savingSnapshots.end()); + } + if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes()) { int saveTime = Clock::timeMs() - m_saveStartTime; @@ -633,7 +641,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) m_totalSaveTime += saveTime; if (saveTime > m_maxSaveTime) m_maxSaveTime = saveTime; - + DEBUG_REPORT_LOG(true,("Save completed in %i. (Average %i, max %i)\n", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime)); LOG("SaveTimes",("Save completed in %i. (Average %i, max %i)", saveTime, m_totalSaveTime/m_saveCount, m_maxSaveTime)); m_lastSaveTime = saveTime; @@ -646,7 +654,7 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) DatabaseProcess::getInstance().sendToCentralServer(saveCompleteMessage, true); LOG("Database",("Sending DatabaseSaveComplete network message to Central.")); } - + { // set the last save completion time (for the monitoring program) time_t theTime = time(0); @@ -655,11 +663,13 @@ void Persister::saveCompleted(Snapshot *completedSnapshot) } else { - SnapshotListType::iterator j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); -DEBUG_FATAL(i==m_savingCharacterSnapshots.end(),("Programmer bug: SaveCompleted() called with a snapshot that wasn't in m_savingSnapshots or m_savingCharacterSnapshots.")); + std::lock_guard lck(m_savingDeleting_mtx); + auto j=std::remove(m_savingCharacterSnapshots.begin(),m_savingCharacterSnapshots.end(),completedSnapshot); + + WARNING(j==m_savingCharacterSnapshots.end(),("saveCompleted() called w/o snap in m_savingSnapshots or m_savingCharacterSnapshots.")); + m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end()); - DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n")); } } diff --git a/engine/server/library/serverDatabase/src/shared/Persister.h b/engine/server/library/serverDatabase/src/shared/Persister.h index 9cc76ac8..24cf49b7 100755 --- a/engine/server/library/serverDatabase/src/shared/Persister.h +++ b/engine/server/library/serverDatabase/src/shared/Persister.h @@ -16,6 +16,8 @@ #include #include //TODO: remove when we clean up newCharacterLock hack +#include + #include "Unicode.h" #include "serverNetworkMessages/MessageToPayload.h" #include "sharedDatabaseInterface/DbModeQuery.h" @@ -116,8 +118,12 @@ class Persister : public MessageDispatch::Receiver ServerSnapshotMap m_newCharacterSnapshots; ObjectSnapshotMap m_objectSnapshotMap; PendingCharactersType m_pendingCharacters; + SnapshotListType m_savingSnapshots; SnapshotListType m_savingCharacterSnapshots; + + std::mutex m_savingDeleting_mtx; + NewCharacterLockType m_newCharacterLock; CharactersToDeleteType * m_charactersToDeleteThisSaveCycle; CharactersToDeleteType * m_charactersToDeleteNextSaveCycle; diff --git a/game/server/application/SwgDatabaseServer/src/shared/core/SwgDatabaseServer.cpp b/game/server/application/SwgDatabaseServer/src/shared/core/SwgDatabaseServer.cpp index 0e331f8c..10e89ee3 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/core/SwgDatabaseServer.cpp +++ b/game/server/application/SwgDatabaseServer/src/shared/core/SwgDatabaseServer.cpp @@ -61,8 +61,6 @@ void SwgDatabaseServer::run() DataCleanupManager cleanupManager; cleanupManager.runDailyCleanup(); - - DatabaseProcess::run(); }