Re: [PATCH 2/4] perf script: Add --max-symbol-bytes to bound ELF symbol memory

From: Alireza Haghdoost

Date: Sat Sep 19 2026 - 14:37:27 EST


> > The counter includes every symbol__new() allocation, but this patch
> > enforces the limit only in the ELF loader, which is the source of the
> > unbounded memory growth addressed here. In this path, reaching the limit
> > can safely produce [unknown] symbols. Other loaders currently treat a
> > failed symbol allocation as an error. Capping those paths would therefore
> > require separate changes whose complexity may outweigh the potential
> > memory savings.
>
> What's the other loaders you meant?
>
> I don't see it produces [unknown] symbols. Do you mean it just stops
> loading symbols when it hits the limit?
>

The other loaders are kallsyms, JIT/perf-map, and libbfd. Their
allocations are counted by symbol__new(), but the current patch
enforces the limit only in the libelf loader. I will name those paths
explicitly in v2 of this patch series.

The loader stops adding ELF symbols once the budget is reached and
warns once. Later unresolved IPs are printed as [unknown] by
symbol_fprintf.c:40 when sym is NULL.