RynthCore as of 2026-10-04 (internal 843c801): RynthNav auto-travel and the navigation map, plugin API v75 (server and titles), launcher with Available plugins, download progress and the update on the front page, opt-in usage statistics, NPC names, radar colours, title-bar text size, FPS limiter, client action unlocks, release 2026.10.4.6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9b5e2765b7
commit
a24ed6df7c
322 changed files with 83009 additions and 7504 deletions
|
|
@ -380,6 +380,19 @@ public static class EntryPoint
|
|||
}
|
||||
}
|
||||
|
||||
// Address-space gate. Every reload leaves the old engine and plugin
|
||||
// copies mapped (NativeAOT can't unload) and costs hundreds of MB of
|
||||
// acclient's 4 GB; below this the next reload, or the play after it,
|
||||
// runs the client out and it dies without a trace (2026-09-28 13:57,
|
||||
// measured 600-670 MB per reload). Refuse and ask for a restart.
|
||||
long freeMb = FreeAddressSpaceMb();
|
||||
if (freeMb >= 0 && freeMb < MinFreeMbForReload)
|
||||
{
|
||||
Log($"ReloadWatcher: reload REFUSED - only {freeMb} MB of address space free (need {MinFreeMbForReload} MB). Restart the client to load the new engine.", "WRN");
|
||||
NotifyReloadRefused(freeMb);
|
||||
continue;
|
||||
}
|
||||
|
||||
// CAS gate. The watcher thread is the only caller, so this should
|
||||
// never trip — but if it ever does (a future code path signals
|
||||
// reload reentrantly, or someone adds a second watcher) we'd
|
||||
|
|
@ -417,6 +430,61 @@ public static class EntryPoint
|
|||
}
|
||||
}
|
||||
|
||||
private const long MinFreeMbForReload = 1200;
|
||||
|
||||
/// <summary>Free (unreserved) address space in MB, or -1 if it can't be read.</summary>
|
||||
private static long FreeAddressSpaceMb()
|
||||
{
|
||||
try
|
||||
{
|
||||
long free = 0;
|
||||
long addr = 0x10000;
|
||||
int size = Marshal.SizeOf<MEMORY_BASIC_INFORMATION>();
|
||||
while (addr < 0xFFFF0000L)
|
||||
{
|
||||
if (VirtualQuery((IntPtr)addr, out MEMORY_BASIC_INFORMATION mbi, (IntPtr)size) == IntPtr.Zero)
|
||||
break;
|
||||
long region = (long)(ulong)mbi.RegionSize;
|
||||
if (region <= 0) break;
|
||||
if (mbi.State == MEM_FREE) free += region;
|
||||
addr = (long)(ulong)mbi.BaseAddress + region;
|
||||
}
|
||||
return free / (1024 * 1024);
|
||||
}
|
||||
catch { return -1; }
|
||||
}
|
||||
|
||||
/// <summary>Tells the running engine, which says so in chat (engines without the export just skip it).</summary>
|
||||
private static void NotifyReloadRefused(long freeMb)
|
||||
{
|
||||
IntPtr module = _engineModule;
|
||||
if (module == IntPtr.Zero) return;
|
||||
IntPtr fn = GetProcAddress(module, "RynthCoreReloadRefused");
|
||||
if (fn == IntPtr.Zero) return;
|
||||
try { Marshal.GetDelegateForFunctionPointer<ReloadRefusedFn>(fn)((int)freeMb); }
|
||||
catch (Exception ex) { Log($"ReloadWatcher: RynthCoreReloadRefused threw {ex.GetType().Name}: {ex.Message}"); }
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate uint ReloadRefusedFn(int freeMb);
|
||||
|
||||
private const uint MEM_FREE = 0x10000;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct MEMORY_BASIC_INFORMATION
|
||||
{
|
||||
public IntPtr BaseAddress;
|
||||
public IntPtr AllocationBase;
|
||||
public uint AllocationProtect;
|
||||
public IntPtr RegionSize;
|
||||
public uint State;
|
||||
public uint Protect;
|
||||
public uint Type;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr VirtualQuery(IntPtr lpAddress, out MEMORY_BASIC_INFORMATION lpBuffer, IntPtr dwLength);
|
||||
|
||||
private static void Reload()
|
||||
{
|
||||
Log("Reload requested.");
|
||||
|
|
|
|||
|
|
@ -26,4 +26,8 @@
|
|||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- GC segment size (hex, 8 MB): reserves 16 MB of acclient's address space instead of 48. See RynthCore.Engine.csproj. -->
|
||||
<ItemGroup>
|
||||
<IlcArg Include="--runtimeopt:GCSegmentSize=800000" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in a new issue