mirror of
https://bitbucket.org/seefoe/src.git
synced 2026-07-15 00:07:34 -04:00
tidies some things up and removes SOE memory manager overriding
This commit is contained in:
@@ -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<int>(Os::getProcessId())),MemoryManager::getProcessVmSizeKBytes(static_cast<int>(Os::getProcessId())),MemoryManager::getCurrentNumberOfAllocations(),MemoryManagerNamespace::ms_allocateCalls));
|
||||
#else
|
||||
LOG("DatabaseMemory",("Bytes used: %lu Open allocations: %d Total Allocations %d",MemoryManager::getCurrentNumberOfBytesAllocated(static_cast<int>(Os::getProcessId())),MemoryManager::getCurrentNumberOfAllocations(),MemoryManagerNamespace::ms_allocateCalls));
|
||||
#endif
|
||||
nextMemoryReportTime=10;
|
||||
}
|
||||
|
||||
nextQueryCountTime-=updateTime;
|
||||
if (nextQueryCountTime < 0)
|
||||
|
||||
@@ -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() )
|
||||
@@ -603,7 +603,6 @@ void Persister::saveCompleted(Snapshot *completedSnapshot)
|
||||
if (i!=m_savingSnapshots.end())
|
||||
{
|
||||
m_savingSnapshots.erase(i, m_savingSnapshots.end());
|
||||
|
||||
if (m_savingSnapshots.empty() && ConfigServerDatabase::getReportSaveTimes())
|
||||
{
|
||||
int saveTime = Clock::timeMs() - m_saveStartTime;
|
||||
@@ -635,16 +634,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."));
|
||||
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
|
||||
m_savingCharacterSnapshots.erase(j, m_savingCharacterSnapshots.end());
|
||||
DEBUG_REPORT_LOG(ConfigServerDatabase::getReportSaveTimes(),("New character save completed\n"));
|
||||
}
|
||||
|
||||
if (completedSnapshot) {
|
||||
delete completedSnapshot;
|
||||
completedSnapshot = nullptr; // in case of double deletes by any other pointers to this thing
|
||||
} else {
|
||||
DEBUG_WARNING(true, ("We just attempted a double delete!"));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -42,14 +42,16 @@ Snapshot::~Snapshot()
|
||||
for (LocatorListType::iterator i=m_locatorList.begin(); i!=m_locatorList.end(); ++i)
|
||||
{
|
||||
delete *i;
|
||||
*i=0;
|
||||
i = m_locatorList.erase(i);
|
||||
}
|
||||
|
||||
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 = m_customStepList.erase(j);
|
||||
}
|
||||
|
||||
++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));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -79,8 +79,8 @@ public:
|
||||
virtual void startLoadAfterSaveComplete() =0;
|
||||
|
||||
protected:
|
||||
typedef std::vector<AbstractTableBuffer*> BufferListType;
|
||||
typedef std::vector<ObjectLocator*> LocatorListType;
|
||||
typedef std::vector<AbstractTableBuffer *> BufferListType;
|
||||
typedef std::vector<ObjectLocator *> LocatorListType;
|
||||
typedef std::vector<CustomPersistStep*> CustomStepListType;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
// ======================================================================
|
||||
|
||||
TaskSaveSnapshot::TaskSaveSnapshot(Snapshot *snapshot) :
|
||||
m_snapshot(snapshot)
|
||||
TaskSaveSnapshot::TaskSaveSnapshot(Snapshot *snapshot) : m_snapshot(snapshot)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,6 +31,8 @@ void TaskSaveSnapshot::onComplete()
|
||||
{
|
||||
m_snapshot->saveCompleted();
|
||||
Persister::getInstance().saveCompleted(m_snapshot);
|
||||
delete m_snapshot;
|
||||
m_snapshot = nullptr;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -22,7 +22,7 @@ class TaskSaveSnapshot : public DB::TaskRequest
|
||||
TaskSaveSnapshot(Snapshot *snapshot);
|
||||
bool process(DB::Session *session);
|
||||
void onComplete();
|
||||
|
||||
|
||||
private:
|
||||
Snapshot *m_snapshot;
|
||||
};
|
||||
|
||||
@@ -96,7 +96,6 @@ static const CommandParser::CmdInfo cmds[] =
|
||||
{"error", 1, "<error message>", "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, "<fileName> <leaksOnly>", "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, "<oid>", "Release Authority for object with oid."},
|
||||
@@ -3518,4 +3517,4 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
|
||||
return true;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
// ======================================================================
|
||||
|
||||
@@ -77,13 +77,6 @@ const GameNetworkMessage & MetricsData::getDataToSend()
|
||||
|
||||
void MetricsData::updateData()
|
||||
{
|
||||
m_data[m_memoryUtilization].m_value = static_cast<int>(MemoryManager::getCurrentNumberOfBytesAllocated(static_cast<int>(Os::getProcessId())) / 1024);
|
||||
m_data[m_memoryUtilizationNoLeakTest].m_value = static_cast<int>(MemoryManager::getCurrentNumberOfBytesAllocatedNoLeakTest() / 1024);
|
||||
m_data[m_memoryAllocated].m_value = MemoryManager::getSystemMemoryAllocatedMegabytes() * 1024;
|
||||
#ifndef _WIN32
|
||||
m_data[m_memoryVmSize].m_value = MemoryManager::getProcessVmSizeKBytes(static_cast<int>(Os::getProcessId()));
|
||||
#endif
|
||||
|
||||
//deal with frame time
|
||||
float frameTime = Clock::frameTime() * 1000;
|
||||
float oldFrameTime = m_frameTimeHistory[m_frameTimeHistoryIndex];
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -41,7 +41,7 @@ static dvoid *mallocHook(dvoid *, size_t size)
|
||||
|
||||
static dvoid *reallocHook(dvoid *, dvoid *memptr, size_t newsize)
|
||||
{
|
||||
return reinterpret_cast<dvoid *>(MemoryManager::reallocate(memptr, newsize));
|
||||
return reinterpret_cast<dvoid *>(realloc(memptr, newsize));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -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<int>(endingNumberOfBytesAllocated - m_startingNumberOfBytesAllocated), m_description));
|
||||
m_description = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ private:
|
||||
|
||||
char const * m_description;
|
||||
PerformanceTimer m_performanceTimer;
|
||||
unsigned long const m_startingNumberOfBytesAllocated;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
*/
|
||||
// ======================================================================
|
||||
|
||||
|
||||
@@ -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();
|
||||
*/
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
@@ -1349,7 +1349,7 @@ void *MemoryManager::reallocate(void *userPointer, size_t newSize)
|
||||
|
||||
if (newSize <= static_cast<size_t>(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;
|
||||
}
|
||||
|
||||
@@ -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 ())
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -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<char const *>(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<int>(postDomBytesAllocated - preDomBytesAllocated)));
|
||||
#endif
|
||||
|
||||
// Release initial file contents buffer.
|
||||
delete [] fileContents;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "sharedFoundation/DynamicVariableList.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <memory>
|
||||
// ======================================================================
|
||||
|
||||
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<IndexKey,ObjvarValue> DataType;
|
||||
|
||||
@@ -141,6 +141,7 @@ SwgSnapshot::SwgSnapshot(DB::ModeQuery::Mode mode, bool useGoldDatabase) :
|
||||
|
||||
SwgSnapshot::~SwgSnapshot()
|
||||
{
|
||||
m_objvarBuffer.~ObjvarBuffer();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "SwgDatabaseServer/Schema.h"
|
||||
#include "SwgDatabaseServer/ScriptBuffer.h"
|
||||
#include "SwgDatabaseServer/WaypointBuffer.h"
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class Session;
|
||||
|
||||
Reference in New Issue
Block a user