RenderTextureMemoryKB ( )

Parameters

None.

Description

Returns the renderer's tracked texture-related memory, in kilobytes.

Use this legacy query to compare texture-related storage across level visits. Coverage follows the renderer: DX12 includes its shadow textures in this category; Metal reports shadows with render targets. WebGPU reports tracked resource sizes, not driver allocation sizes. Linux uses the shared WebGPU renderer through native Dawn/Vulkan, not browser memory.

Read after RenderWorld and Flip for the latest published frame. Existing return values and their kilobyte units are unchanged; the query returns 0 before Graphics3D. Resource retirement and reuse can delay a reduction after FreeTexture, so growth alone does not prove a leak. This is not total process or GPU heap usage.

The debugger Memory view and MemorySnapshot label each supported renderer metric's availability, scope and accounting basis. They keep renderer information separate from Runtime accounted bytes and do not wait for GPU completion. See the Memory reporting guide.

See also: RenderGeometryMemoryKB, LoadTexture, CreateTexture, DrawRenderStats.

Example

; RenderTextureMemoryKB Example
; -----------------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

SeedRnd MilliSecs()

camera=CreateCamera()
PositionEntity camera,0,2,-12

light=CreateLight()
RotateEntity light,45,45,0

; Space spawns crates with unique 256x256 textures; C frees them all again
Dim crates(19),skins(19)
count=0

While Not KeyDown(1)

    ; Each press creates a NEW texture, so tracked texture memory grows
    If KeyHit(57) And count<20 Then
        skins(count)=CreateTexture(256,256)
        SetBuffer TextureBuffer(skins(count))
        ClsColor Rand(60,255),Rand(60,255),Rand(60,255)
        Cls
        SetBuffer BackBuffer()
        crates(count)=CreateCube()
        EntityTexture crates(count),skins(count)
        PositionEntity crates(count),Rnd(-6,6),Rnd(-2,2),Rnd(0,8)
        count=count+1
    EndIf

    ; C frees every crate and its texture, releasing the memory
    If KeyHit(46) Then
        For n=0 To count-1
            FreeEntity crates(n)
            FreeTexture skins(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

    ; RenderTextureMemoryKB tracks targets, shadows, cached textures and uploads
    Text 0,0,"Space: spawn textured crate   C: free all   Arrows: camera   Esc: exit"
    Text 0,20,"Unique textures: "+count+"   RenderTextureMemoryKB() = "+RenderTextureMemoryKB()+" KiB"

    Flip

Wend

End

Index