feat: Updates serialization to use MMF (considerable memory savings) (#1841)
### Summary Updates the serialization strategy to use `MemoryMappedFile` instead of thick buffers. This has the benefit of being on-par with the current implementation (based on hardware/OS), however won't incur the double-memory issue. > [!Important] > **Developer Note** > The `BinaryFileWriter` and `BinaryFileReader` has been removed in favor of `MemoryMapFileWriter` and `UnmanagedDataReader`
This commit is contained in:
parent
3b84c8052c
commit
8ec203f387
27 changed files with 1271 additions and 941 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2023 - ModernUO Development Team *
|
||||
* Copyright 2019-2024 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: BufferReader.cs *
|
||||
* *
|
||||
|
|
@ -29,9 +29,9 @@ public class BufferReader : IGenericReader
|
|||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(BufferReader));
|
||||
|
||||
private Dictionary<ulong, string> _typesDb;
|
||||
private Encoding _encoding;
|
||||
private byte[] _buffer;
|
||||
private readonly Dictionary<ulong, string> _typesDb;
|
||||
private readonly Encoding _encoding;
|
||||
private readonly byte[] _buffer;
|
||||
private int _position;
|
||||
|
||||
public long Position => _position;
|
||||
|
|
@ -44,21 +44,6 @@ public class BufferReader : IGenericReader
|
|||
_typesDb = typesDb;
|
||||
}
|
||||
|
||||
public BufferReader(byte[] buffer, DateTime lastSerialized, Dictionary<ulong, string> typesDb = null) : this(buffer)
|
||||
{
|
||||
LastSerialized = lastSerialized;
|
||||
_typesDb = typesDb;
|
||||
}
|
||||
|
||||
public void Reset(byte[] newBuffer, out byte[] oldBuffer)
|
||||
{
|
||||
oldBuffer = _buffer;
|
||||
_buffer = newBuffer;
|
||||
_position = 0;
|
||||
}
|
||||
|
||||
public DateTime LastSerialized { get; init; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string ReadString(bool intern = false) => ReadBool() ? ReadStringRaw(intern) : null;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue