Skip to content

Commit

Permalink
Added reference counting leak check to integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
FredyH committed Jan 24, 2022
1 parent 18046a0 commit a2b5f29
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions IntegrationTest/lua/mysqloo/testframework.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ function TestFramework:OnCompleted()
else
MsgC(Color(255, 255, 255), "All allocated objects were freed\n")
end


diffBefore = TestFramework.ReferenceCreatedCount - TestFramework.ReferenceFreedCount
diffAfter = mysqloo.referenceCreatedCount() - mysqloo.referenceFreedCount()
if (diffAfter > diffBefore) then
MsgC(Color(255, 255, 255), "Found potential memory leak with ", diffAfter - diffBefore, " new references created that were not freed\n")
else
MsgC(Color(255, 255, 255), "All created references were freed\n")
end


MsgC(Color(255, 255, 255), "Lua Heap Before: ", TestFramework.LuaMemory, " After: ", collectgarbage("count"), "\n")
end)
end
Expand All @@ -79,6 +90,8 @@ function TestFramework:Start()
TestFramework.CurrentIndex = 0
TestFramework.SuccessCount = 0
TestFramework.FailureCount = 0
TestFramework.ReferenceCreatedCount = mysqloo.referenceCreatedCount()
TestFramework.ReferenceFreedCount = mysqloo.referenceFreedCount()
TestFramework.AllocationCount = mysqloo.allocationCount()
TestFramework.DeallocationCount = mysqloo.deallocationCount()
TestFramework.LuaMemory = collectgarbage("count")
Expand Down

0 comments on commit a2b5f29

Please sign in to comment.