RenderGeometryMemoryKB ( )
Parameters
| None. |
Description
|
Returns the renderer's tracked geometry memory, in kilobytes. This is the mesh-side companion to RenderTextureMemoryKB: the committed memory holding vertex and index data for your meshes, terrains and other geometry, plus geometry uploads in flight. Like its sibling it tracks real allocations, so it rises when you load or build meshes and falls when you free them. Use it to catch geometry leaks (a number that only ever climbs across level changes means meshes are not being freed), to compare the real cost of models ("what does this tree pack actually weigh?"), and to budget levels for smaller machines. Watching it alongside RenderTextureMemoryKB after each load screen gives you a two-line memory report for free. Read it after RenderWorld and Flip for the latest frame's value; it returns 0 before Graphics3D. Requires Extended mode. See also: RenderTextureMemoryKB, LoadMesh, FreeEntity, DrawRenderStats. |
Example
; RenderGeometryMemoryKB Example ; ------------------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,3,-14 light=CreateLight() RotateEntity light,45,45,0 ; Space spawns unique asteroid meshes; C frees them all again Dim rocks(49) count=0 While Not KeyDown(1) ; Each press creates NEW sphere geometry, so committed memory grows If KeyHit(57) And count<50 Then rocks(count)=CreateSphere(32) PositionEntity rocks(count),Rnd(-6,6),Rnd(-3,3),Rnd(0,8) EntityColor rocks(count),130,120,110 count=count+1 EndIf ; C frees every spawned mesh, releasing its geometry memory If KeyHit(46) Then For n=0 To count-1 FreeEntity rocks(n) Next count=0 EndIf ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld ; RenderGeometryMemoryKB tracks committed geometry and upload memory Text 0,0,"Space: spawn asteroid C: free all Arrows: camera Esc: exit" Text 0,20,"Unique meshes: "+count+" RenderGeometryMemoryKB() = "+RenderGeometryMemoryKB()+" KiB" Flip Wend End
Index