this one was still bugging me so played with it some more and i believe the problem was that we weren't deleting the object, just the body. try this:
// Project: MemLeakTest060820
// Created: 2020-06-08
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "MemLeakTest060820" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
SetWindowPosition(0,100)
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetVSync(1)
Create3DPhysicsWorld(40) // 40 DEFAULT SIZE
Set3dPhysicsGravity(0.0,-10.0,0.0) // -10 DEFAULT
SetSunActive(1)
SetSunDirection(0.0,-70.0,0.0)
SetShadowMappingMode(3)
SetShadowSmoothing(1)
Ground = CreateObjectBox(100,10,100)
SetObjectPosition(Ground,50,0,50)
Create3dPhysicsStaticBody(Ground)
SetObject3DPhysicsRestitution(Ground,0.5)
SetObjectColor(Ground,128,0,0,255)
SetObjectReceiveShadow(Ground,1)
GLOBAL Ball as Integer
DoBall()
SetCameraPosition(1,0,100,-100)
do
If GetPointerPressed() then DoBall()
SetCameraLookAt(1, GetObjectX(Ball), GetObjectY(Ball), GetObjectZ(Ball), 0)
Print( ScreenFPS() )
Step3dPhysicsWorld()
Sync()
loop
Function DoBall()
If GetObjectExists(Ball)
Delete3DPhysicsBody(Ball)
DeleteObject(Ball)
Endif
Ball = CreateObjectSphere(10,10,10)
SetObjectPosition(Ball,Random(10,90),100,Random(10,90) )
SetObjectColor(Ball, Random(128,255), Random(128,255), Random(128,255), 255)
SetObjectCastShadow(Ball,1)
Create3dPhysicsDynamicBody(Ball)
SetObjectShapeSphere(Ball)
SetObject3DPhysicsRestitution(Ball,0.8)
SetObject3DPhysicsCanSleep(Ball,0)
EndFunction
i don't know if it was, perhaps, re-creating multiple bullet shapes associated with the object(s) in the OP or what (& i don't see a GetObjectShape/BodyExists()-type command), but i see no rise in memory with the this code.
please test?
NOPE: i started mashing LMB and the memory started rising after ~10-15 clicks. less noticeable than the OP code with 1/10 the balls... back to the drawing board
AND: identical behavior
without deleting anything:
// Project: MemLeakTest060820
// Created: 2020-06-08
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "MemLeakTest060820" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
SetWindowPosition(0,100)
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetVSync(1)
Create3DPhysicsWorld(40) // 40 DEFAULT SIZE
Set3dPhysicsGravity(0.0,-10.0,0.0) // -10 DEFAULT
SetSunActive(1)
SetSunDirection(0.0,-70.0,0.0)
SetShadowMappingMode(3)
SetShadowSmoothing(1)
Ground = CreateObjectBox(100,10,100)
SetObjectPosition(Ground,50,0,50)
Create3dPhysicsStaticBody(Ground)
SetObject3DPhysicsRestitution(Ground,0.5)
SetObjectColor(Ground,128,0,0,255)
SetObjectReceiveShadow(Ground,1)
GLOBAL Ball as Integer
DoBall()
SetCameraPosition(1,0,100,-100)
do
If GetPointerPressed() then DoBall()
SetCameraLookAt(1, GetObjectX(Ball), GetObjectY(Ball), GetObjectZ(Ball), 0)
Print( ScreenFPS() )
Step3dPhysicsWorld()
Sync()
loop
Function DoBall()
If GetObjectExists(Ball) = 0
Ball = CreateObjectSphere(10,10,10)
SetObjectCastShadow(Ball,1)
Endif
Create3DPhysicsKinematicBody( Ball )
SetObjectPosition(Ball,Random(10,90),100,Random(10,90) )
SetObjectColor(Ball, Random(128,255), Random(128,255), Random(128,255), 255)
Create3dPhysicsDynamicBody(Ball)
EndFunction
so, it's the body?