mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
gg: allow for -d gg_memory_trace_frame
to be used in combination with -prealloc -d prealloc_dump
This commit is contained in:
parent
388413a2c8
commit
c03d7d1cb2
1 changed files with 16 additions and 0 deletions
|
@ -339,6 +339,7 @@ fn gg_frame_fn(mut ctx Context) {
|
|||
}
|
||||
|
||||
ctx.record_frame()
|
||||
ctx.memory_trace_frame()
|
||||
|
||||
if ctx.ui_mode && !ctx.needs_refresh {
|
||||
// println('ui mode, exiting')
|
||||
|
@ -884,3 +885,18 @@ pub fn wait_events() {
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// memory_trace_frame creates a small allocation at the start of each frame,
|
||||
// that is easy to search for in memdump.bin files, created with:
|
||||
// -prealloc -d prealloc_memset -d prealloc_memset_value=65 -d prealloc_dump -d gg_memory_trace_frame
|
||||
@[if gg_memory_trace_frame ?; manualfree]
|
||||
fn (mut ctx Context) memory_trace_frame() {
|
||||
frame_tag_size := 61 // uneven, and easy to spot in heaptrack histograms as well
|
||||
unsafe {
|
||||
frame_tag := &u8(vcalloc(frame_tag_size))
|
||||
C.snprintf(frame_tag, frame_tag_size, c'@@ gg_memory_trace_frame: %06d ', ctx.frame)
|
||||
frame_tag[frame_tag_size - 2] = `@`
|
||||
frame_tag[frame_tag_size - 1] = `@`
|
||||
free(frame_tag)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue