- Home /
About coroutine and the GC
I currently read over about implementing a coroutine system for killing them off, starting them and so on. I wrapped this behavior as a "Task" class. If I want to immediately kill off and start another coroutine, I do this:
public Task(IEnumerator coroutine, bool isPaused)
{
_coroutine = coroutine;
if (!isPaused)
{
FSM.instance.StartCoroutine(startTask());
}
}
public void replaceTask(IEnumerator task, ref Task<T> lt)
{
kill();
lt = new Task<T>(task, false);
}
My ref lt above is the Task instance I set in any particular class and I set it to a new Task as I immediately want my new coroutine running.
I see here that a reference to the older task is lost once I set my 'lt' variable to a new task. My question is, will the current task still run to completion even though nothing is referencing it after this or will the GC kill off anything left to run in the current old coroutine?
I could have it so a new task is only started once I get an event of completion but I don't particularly want to wait for this.
Your answer
Follow this Question
Related Questions
know how many free memory on System? Windows Standalone 1 Answer
AudioClip.preloadAudioData not working 0 Answers
Where is Actually The Prefabs Stored Before Instantiation? RAM or Storage(Internal Memory) 2 Answers
[CRASH] Memory can not be "read" / "write" 1 Answer
iOS VideoPlayer doesn't unload temp RenderTexture in 2019 0 Answers