Optimize GC while prehandling.

This commit is contained in:
2023-04-18 09:35:37 +08:00
parent f4411629e4
commit a2c5850fcd
2 changed files with 18 additions and 9 deletions

View File

@@ -250,6 +250,13 @@ namespace Cryville.Crtr {
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
#endif
);
if (ContainerState.RMVPool != null) {
statusbuf.AppendFormat(
"\nPools: RMV {0}, MC {1}",
ContainerState.RMVPool.RentedCount,
ContainerState.MCPool.RentedCount
);
}
if (loadThread != null) {
statusbuf.AppendFormat(
"\n(Loading textures) Progress: {0:P}\n(Loading files) Progress: {1:P}",
@@ -259,10 +266,8 @@ namespace Cryville.Crtr {
if (prehandler != null) statusbuf.AppendFormat("\n(Prehandling) Progress: {0:P}", prehandler.Progress);
if (started) {
statusbuf.AppendFormat(
"\nStates: c{0} / b{1}\nPools: RMV {2}, MC {3}",
cbus.ActiveStateCount, bbus.ActiveStateCount,
ContainerState.RMVPool.RentedCount,
ContainerState.MCPool.RentedCount
"\nStates: c{0} / b{1}",
cbus.ActiveStateCount, bbus.ActiveStateCount
);
statusbuf.AppendFormat(
"\nSTime: {0:G17}s {3} {4}\ndATime: {1:+0.0ms;-0.0ms;0} {3} {4}\ndITime: {2:+0.0ms;-0.0ms;0} {3} {5}",

View File

@@ -37,7 +37,10 @@ namespace Cryville.Crtr.Event {
private set {
if (m_active == value) return;
m_active = value;
if (!m_active && CloneType == 1) Dispose();
if (!m_active) {
if (CloneType == 1) Dispose();
else if (CloneType >= 16) ReleasePools();
}
if (Parent != null) {
if (m_active) Parent.ActiveChildren.Add(Container);
else Parent.ActiveChildren.Remove(Container);
@@ -191,10 +194,7 @@ namespace Cryville.Crtr.Event {
if (Disposed) return;
Disposed = true;
if (CloneType == 1) Handler.Dispose();
if (CloneType == 1 || CloneType == 17) {
_rmvpa.ReturnAll();
_mcpa.ReturnAll();
}
ReleasePools();
foreach (var s in Children)
s.Value.Dispose();
}
@@ -203,6 +203,10 @@ namespace Cryville.Crtr.Event {
s.Value.DisposeAll();
Handler.DisposeAll();
}
public void ReleasePools() {
_rmvpa.ReturnAll();
_mcpa.ReturnAll();
}
public void AttachHandler(ContainerHandler h) {
if (Handler != null)