fix(render3d, runtime): a glTF document is freed whole, layouts found by number, block records reused
- Json.free_all (value_free_all): a parsed tree's nodes, lists and strings. render3d frees each glTF document that way at the next load; the names kept out of it are copies (a primitive's material, a skin's joints, an animation clip's name in ludic.anim) - a model's strings were ~640 KB left behind per load - jp_number made a digits list per decimal in a document and never freed it - gvk_layout_id matches a mesh's layout as numbers in a scratch made once, against the layouts known end to end; a new mesh no longer builds a key string - gvk_mem_new puts a new block into the record of one given back rather than appending, so a buffer made again every few frames no longer grows the block lists steady.ludic adds a glTF parsed and freed whole 200 times: 0 bytes (38,400 before the digits fix), beside the buffer path and the frame, still 0. A model loaded and let go still keeps ~2 KB a round (texture and buffer handles are not reused yet); it is bounded at 8 KB a round. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
866037a0d7
commit
a465984c52
9 changed files with 114 additions and 16 deletions
|
|
@ -489,6 +489,7 @@ namespace Json {
|
|||
alias encode(value) = json_encode
|
||||
alias parse(text) = json_parse
|
||||
alias free(value) = json_free
|
||||
alias free_all(value) = json_free_all
|
||||
}
|
||||
namespace Xml {
|
||||
alias parse(text) = xml_parse
|
||||
|
|
|
|||
|
|
@ -384,6 +384,21 @@ function value_free(v: Val) -> void {
|
|||
free(v)
|
||||
}
|
||||
function json_free(v: Val) -> void { value_free(v) }
|
||||
# ... and its strings too - every string value and object key the parser made - for a tree whose
|
||||
# reader copied what it keeps (render3d's glTF documents): a parse left otherwise gives back the
|
||||
# nodes and keeps every name, ~640 KB a model
|
||||
function value_free_all(v: Val) -> void {
|
||||
if v == null { return }
|
||||
if v.tag == 4 and v.txt != null { free(v.txt) }
|
||||
if v.kids != null {
|
||||
for i in 0 .. len(v.kids) { value_free_all(v.kids[i]) }
|
||||
if v.keys != null { for i in 0 .. len(v.keys) { if v.keys[i] != null { free(v.keys[i]) } } }
|
||||
free(v.kids)
|
||||
free(v.keys)
|
||||
}
|
||||
free(v)
|
||||
}
|
||||
function json_free_all(v: Val) -> void { value_free_all(v) }
|
||||
|
||||
function jp_value(p: JP) -> Val {
|
||||
jp_skip_ws(p)
|
||||
|
|
@ -467,6 +482,7 @@ function jp_number(p: JP) -> Val {
|
|||
frac = (digits[di] * 65536 + frac) / 10
|
||||
di -= 1
|
||||
}
|
||||
free(digits) # one list per decimal in the document, never given back
|
||||
var raw = ip * 65536 + frac
|
||||
raw = jp_exponent(p, raw)
|
||||
if neg != 0 { raw = -raw }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue