Skip to content

Commit a2b5f29

Browse files
committed
Added reference counting leak check to integration test
1 parent 18046a0 commit a2b5f29

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

IntegrationTest/lua/mysqloo/testframework.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ function TestFramework:OnCompleted()
6868
else
6969
MsgC(Color(255, 255, 255), "All allocated objects were freed\n")
7070
end
71+
72+
73+
diffBefore = TestFramework.ReferenceCreatedCount - TestFramework.ReferenceFreedCount
74+
diffAfter = mysqloo.referenceCreatedCount() - mysqloo.referenceFreedCount()
75+
if (diffAfter > diffBefore) then
76+
MsgC(Color(255, 255, 255), "Found potential memory leak with ", diffAfter - diffBefore, " new references created that were not freed\n")
77+
else
78+
MsgC(Color(255, 255, 255), "All created references were freed\n")
79+
end
80+
81+
7182
MsgC(Color(255, 255, 255), "Lua Heap Before: ", TestFramework.LuaMemory, " After: ", collectgarbage("count"), "\n")
7283
end)
7384
end
@@ -79,6 +90,8 @@ function TestFramework:Start()
7990
TestFramework.CurrentIndex = 0
8091
TestFramework.SuccessCount = 0
8192
TestFramework.FailureCount = 0
93+
TestFramework.ReferenceCreatedCount = mysqloo.referenceCreatedCount()
94+
TestFramework.ReferenceFreedCount = mysqloo.referenceFreedCount()
8295
TestFramework.AllocationCount = mysqloo.allocationCount()
8396
TestFramework.DeallocationCount = mysqloo.deallocationCount()
8497
TestFramework.LuaMemory = collectgarbage("count")

0 commit comments

Comments
 (0)