Page MenuHomeFeedback Tracker

Memory leak when returning a new instance and invoking a method in the same return statement
Assigned, UrgentPublic

Description

By observing class count in the script profiler UI, in a static function, returning a newly created instance of a class and invoking a method returning that instance in the same return statement causes a memory leak.
Same behaviour has been observed for both managed and non-managed classes.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
  1. Declare the following class
class LeakTest {
	static LeakTest leak() {
		return (new LeakTest()).getThis();
	}
	
	LeakTest getThis() {
		return this;
	}
}
  1. Invoke leak()
  2. Observe LeakTest instances count
Additional Information

Tested with experimental build, DayZDiag.exe 1.21.156073

Event Timeline

simonvic created this task.Apr 22 2023, 8:55 PM
simonvic renamed this task from Possible memory leak to Memory leak when returning a new instance and invoking a method in the same return statement.Apr 23 2023, 8:00 PM
simonvic updated the task description. (Show Details)
simonvic edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Apr 24 2023, 2:47 PM