Skip to content

Conversation

codeinred
Copy link
Contributor

I'm currently working on a memory profiler, and I noticed that 880 bytes was always being allocated at the start of any program that I tested. This allocation was due to punctuators_and_operators, inside cpptrace.

image

I've created this MR to convert punctuators_and_operators into a statically allocated array, so that cpptrace doesn't do any allocations on initialization.

@ZXShady
Copy link

ZXShady commented Aug 23, 2025

decalre the array as static and constexpr otherwise it will be reconstructed everytime on the stack

@codeinred
Copy link
Contributor Author

@ZXShady this array is a global constant. It’s namespace-scope. Some older compilers don’t support constexpr std::string_view, and that’s why i didn’t use constexpr here. if you look at the surrounding arrays, none of those are declared constexpr either

@ZXShady
Copy link

ZXShady commented Aug 25, 2025

my bad, thought it was function local

Copy link
Owner

@jeremy-rifkin jeremy-rifkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jeremy-rifkin jeremy-rifkin changed the base branch from main to dev September 17, 2025 02:52
@jeremy-rifkin jeremy-rifkin merged commit 1bc5ebd into jeremy-rifkin:dev Sep 17, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants