• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

Revision7d0b7c5c801c5411bd8fa9c78cbb0e219d0572c2 (tree)
Time2020-04-26 05:55:25
Authormelchior <melchior@user...>
Commitermelchior

Log Message

Potential fix for Memory leak - Clear (some) Metadata post persist

Change Summary

Incremental Difference

--- a/Automap/Data/ColumnMeta.cs
+++ b/Automap/Data/ColumnMeta.cs
@@ -128,18 +128,22 @@ namespace Automap
128128 [ProtoAfterDeserialization]
129129 private void PostProcess()
130130 {
131- if (this.HeightMap == null) this.HeightMap = new ushort[ChunkSize, ChunkSize];
131+ ChunkSize = (ChunkSize == byte.MinValue) ? (byte)32 : ChunkSize;//Not good - if chunk wasn't 32 orignally!
132+
133+ if (this.HeightMap == null || this.HeightMap.Length != (ChunkSize * ChunkSize)) {
134+ this.HeightMap = new ushort[ChunkSize, ChunkSize];
135+ }
132136
133137 if (_flattened_HeightMap != null)
134138 {
135139 int col, row;
136- _ = new BitVector32(0);
140+ var bitMasker = new BitVector32(0);
137141 var rowSection = BitVector32.CreateSection((short) (ChunkSize - 1));
138142 var colSection = BitVector32.CreateSection((short) (ChunkSize - 1), rowSection);
139143
140144 for (uint rowcol = 0; rowcol < (ChunkSize * ChunkSize); rowcol++)
141145 {
142- BitVector32 bitMasker = new BitVector32(data: (int) rowcol);
146+ bitMasker = new BitVector32(data: (int) rowcol);
143147 row = bitMasker[rowSection];
144148 col = bitMasker[colSection];
145149 HeightMap[col, row] = _flattened_HeightMap[rowcol];
@@ -231,5 +235,14 @@ namespace Automap
231235 base.Add(newItem);
232236 }
233237
238+ public void ClearMetadata( )
239+ {
240+ for (int i = 0, maxItemsCount = this.Items.Count; i < maxItemsCount; i++) {
241+ ColumnMeta entry = this.Items[i];
242+ entry.HeightMap = null;
243+ entry.RockRatio = null;//Also regenerated when any chunk in a column is changed...
244+ }
245+ }
246+
234247 }
235-}
\ No newline at end of file
248+}
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -53,7 +53,7 @@ namespace Automap
5353
5454 internal CommandType CurrentState { get; set; }
5555 //Run status, Chunks processed, stats, center of map....
56- private uint nullChunkCount, updatedChunksTotal;
56+ private uint nullChunkCount, nullMapCount, updatedChunksTotal;
5757 private Vec2i startChunkColumn;
5858
5959 private readonly int chunkSize;
@@ -184,7 +184,7 @@ namespace Automap
184184 if (mapChunk == null)
185185 {
186186 Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
187- nullChunkCount++;
187+ nullMapCount++;
188188 columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
189189 continue;
190190 }
@@ -219,8 +219,9 @@ namespace Automap
219219 columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
220220 Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key);
221221 }
222-
223222 }
223+ //Cleanup persisted Metadata...
224+ chunkTopMetadata.ClearMetadata( );
224225 }
225226
226227 UpdateStatus(this.updatedChunksTotal, this.nullChunkCount, updatedChunks);
@@ -500,6 +501,7 @@ namespace Automap
500501 #if DEBUG
501502 Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
502503 #endif
504+ nullChunkCount++;
503505 continue;
504506 }
505507
@@ -512,14 +514,12 @@ namespace Automap
512514
513515 foreach (var blockEnt in chunkData.BlockEntities)
514516 {
515-
516517 if (blockEnt != null && blockEnt.Block != null && BlockID_Designators.ContainsKey(blockEnt.Block.BlockId))
517518 {
518519 var designator = BlockID_Designators[blockEnt.Block.BlockId];
519520 designator.SpecialAction(ClientAPI, POIs, blockEnt.Pos.Copy(), blockEnt.Block);
520521 }
521522 }
522-
523523 }
524524 /********************* Chunk/Column BLOCKs scanning ****************/
525525 //Heightmap, Stats, block tally
@@ -528,6 +528,10 @@ namespace Automap
528528 int X_index, Y_index, Z_index;
529529 X_index = Y_index = Z_index = 0;
530530
531+ //Ensure ChunkData Metadata fields arn't null...due to being tossed out
532+ if (chunkMeta.HeightMap == null) { chunkMeta.HeightMap = new ushort[chunkSize, chunkSize]; }
533+ if (chunkMeta.RockRatio == null) { chunkMeta.RockRatio = new Dictionary<int, uint>(10); }
534+
531535 do
532536 {
533537 do