First I create a empty sence whith a AstarPath Distable,
AstarPath setting like pic, load data fome cache, And Cache StartUp is enable.
After Start the Scene, the mono is 13.9mb
Then I click the Init button, the astarpath enabled and the cache loadsuccess. the mono is 55.5mb.
Then I click the Destroy button, DestroyImmediate the Astar and Call GC.Collect()
But the mono is 46.3mb
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Pathfinding.Util;
using Pathfinding;
public class Reload : MonoBehaviour
{
public AstarPath astar;
public Button init;
public Button destroy;
void Start()
{
init.onClick.AddListener(Init);
destroy.onClick.AddListener(Destroy);
}
private void Init() {
Debug.LogError("Init");
astar.gameObject.SetActive(true);
}
void Destroy() {
Debug.LogError("Destroy");
DestroyImmediate(astar);
ListPool<GraphNode>.Clear();
ListPool<Int3>.Clear();
ListPool<Vector3>.Clear();
ListPool<int>.Clear();
ListPool<float>.Clear();
ListPool<ABPath>.Clear();
ListPool<GridNode>.Clear();
GC.Collect();
}
private void OnDestroy() {
destroy.onClick.RemoveListener(Destroy);
}
}