On 08.03.2024 07:30, Eric Raible wrote:
I guess that I just want the numbers to add up.
Using your example:
1) -DMEM_DEBUG -DCONFIG_RUNMEM_RO=0
2) your test.c
3) but I added an early return to tcc_delete() to no-op it
Running: valgrind tcc -nostdlib -vv -bench -run test.c
produced:
tcc version 0.9.28rc 2024-03-03 mob@9d2068c6* (AArch64 Linux)
-> test.c
---------------------------------------------
0: .text 0x4ccb000 len 00020 align 1000
1: .data.ro 0x4ccb020 len 00004 align 0008
2: .data 0x4ccb028 len 00004 align 0008
2: .bss 0x4ccb030 len 00004 align 0008
---------------------------------------------
protect rwx 0x4ccb000 len 01000
---------------------------------------------
# 3030 idents, 4 lines, 92 bytes
# 0.463 s, 8 lines/s, 0.0 MB/s
# text 32, data.rw <http://data.rw> 4, data.ro <http://data.ro> 4, bss 4 bytes
# memory usage: 8192 to run, 649 symbols, 2901 other, 1639290 max (bytes)
mem_cur_size=11742 (bytes)
So tcc_print_stats() says 11742, but then displays values totaling 11786.
What 11786 ?
8192 + 649 + 2901 = 11742
> ==2188==
> ==2188== HEAP SUMMARY:
> ==2188== in use at exit: 14,814 bytes in 32 blocks
>
> And valgrind reports 14814. I have never seen valgrind wrong about this,
> and especially so b.c. my (luckily-correct) allocator reported 14814 as well.
There is nothing wrong here: 11742 + 32 blocks * 96 = 14814
Where 96 is the size of tcc's mem_debug extra header.
If you want to see the 11742 from valgrind then you just need to
run the same example with a normal tcc compiled without MEM_DEBUG.
Which makes sense I would think.
But when showing the example with MEM_DEBUG and -bench -vv I
did not expect you to doubt the numbers in the first place.
Rather I just was trying to show how you could get some numbers
for your own real case instead. Which as you suspect could be
minimized from 29kB down to 1-2 kB. Most likely impossible but
if we had some numbers we could tell also why.
-- gr
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel