Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Huge memory savings (and more to come)
Browse files Browse the repository at this point in the history
  Custom Record Pool Allocators and lazy string / raw record copying
    Minimum memory use (Oblivion.esm only) reduced from 130MB to 105MB
    Max memory use (Oblivion.esm only) reduced from 635MB to 466MB
Custom Record Pool Allocators
  Loads Oblivion.esm faster by ~.2 seconds
  Iterating through records should be faster due to improved locality (not benched)
StringRecord, NonNullStringRecord, and RawRecord no longer load into memory when read from disk
  Instead they simply point to the data on disk, and only copy into memory when written
  Saves ~15MB on max memory use (Oblivion.esm only)
StringRecord, NonNullStringRecord cleaned up and underused functions removed
  Next step is a custom string allocator
Call Count and Timing macros now display DeleteCollection properly
Creating an EditorID keyed record (Ob::GMSTRecord, Ob::MGEFRecord) no longer copies the editorID twice
Added a series of generic debug vars for misc use if CBASH_DEBUG_VARS is defined
Added UnorderedPackedStrings::Copy, and used in place of std::vector<StringRecord> in Oblivion records
Fixed? possible corruption of OBME mgefCode when copying or creating a new record
  • Loading branch information
waruddar committed Jun 5, 2011
1 parent da484c7 commit 0ad70f1
Show file tree
Hide file tree
Showing 26 changed files with 950 additions and 635 deletions.
Binary file modified CBash.suo
Binary file not shown.
782 changes: 539 additions & 243 deletions CBash/Allocator.h

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion CBash/CBash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ int handle_program_memory_depletion(size_t size)
CPPDLLEXTERN Collection * CreateCollection(STRING const ModsPath, const UINT32 CollectionType)
{
PROFILE_FUNC

try
{
_set_new_handler(handle_program_memory_depletion);
Expand Down Expand Up @@ -276,8 +277,9 @@ CPPDLLEXTERN SINT32 DeleteCollection(Collection *CollectionID)
return 0;
}
Collections.clear();

#ifdef CBASH_CALLCOUNT
cbcounter.end();
printer("counts = [");
for(std::map<char *, unsigned long>::iterator it = CallCount.begin(); it != CallCount.end(); ++it)
printer("(%d, '%s'),", it->second, it->first);
Expand All @@ -287,6 +289,7 @@ CPPDLLEXTERN SINT32 DeleteCollection(Collection *CollectionID)
#endif
#endif
#ifdef CBASH_CALLTIMING
cbtimer.end();
double TotTime = 0.0f;
printer("times = [");
for(std::map<char *, double>::iterator it = CallTime.begin(); it != CallTime.end(); ++it)
Expand Down
2 changes: 1 addition & 1 deletion CBash/Collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ Record * Collection::CopyRecord(ModFile *&curModFile, Record *&curRecord, ModFil
}

//Create the record copy
RecordCopy = DestModFile->CreateRecord(curRecord->GetType(), DestRecordEditorID ? DestRecordEditorID : curRecord->GetEditorIDKey(), curRecord, ParentRecord, options);
RecordCopy = DestModFile->CreateRecord(curRecord->GetType(), DestRecordEditorID, curRecord, ParentRecord, options);
if(RecordCopy == NULL)
{
printer("CopyRecord: Error - Unable to create the copied record (%08X). An unknown error occurred when copying the record from \"%s\" to \"%s\".\n", curRecord->formID, DestModFile->reader.getModName(), curModFile->reader.getModName());
Expand Down
Loading

0 comments on commit 0ad70f1

Please sign in to comment.