You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have implemented standard allocators support in my fork to be able to use spdlog in a project that relies on allocators for memory management. The goal was, to avoid making any allocation inside spdlog from the runtime, and only use supplied allocators for that. In brief, the changes are:
Many classes are parameterized with allocator types, including logger, formatter, sink, backtracer, registry, and others. Legacy behaviour can be achieved by using std::allocator as an argument for them. Those of them that are presumably most commonly used have std::allocator as the default argument, and can be used without code change.
The templatized classes have instantiations with std::allocator added to the cpps, so that it's possible to use them from a shared lib in the old way. In order to use spdlog with different allocators, it has to be used as header only.
The templatized classes now take allocator instance as a ctor argument.
I would like to tidy these features up and deliver them upstream. But before starting with that, I would like a feedback from the maintainers if this change is welcome. There is a lot of code to be reviewed, and there are some compatibility implications that, I believe, can be worked on.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have implemented standard allocators support in my fork to be able to use
spdlogin a project that relies on allocators for memory management. The goal was, to avoid making any allocation insidespdlogfrom the runtime, and only use supplied allocators for that. In brief, the changes are:Many classes are parameterized with allocator types, including
logger,formatter,sink,backtracer,registry, and others. Legacy behaviour can be achieved by usingstd::allocatoras an argument for them. Those of them that are presumably most commonly used havestd::allocatoras the default argument, and can be used without code change.The templatized classes have instantiations with
std::allocatoradded to the cpps, so that it's possible to use them from a shared lib in the old way. In order to usespdlogwith different allocators, it has to be used as header only.The templatized classes now take allocator instance as a ctor argument.
There is support for stateful allocators, and for both propagating and non-propagating allocators. The latter requires fmt 12 (
fmt::basic_memory_buffer<...,std::pmr::polymorphic_allocator>is not moveable fmtlib/fmt#4487, Handle allocator propagation in basic_memory_buffer::move, Fix #4487 fmtlib/fmt#4490) and C++17.The following allocations are now done using allocators: formatting buffers, logger names, vectors of sinks.
Probably there are bits that are not covered yet, but I believe that's a starting point good enough, tried and tested in the project it's made for.
More details: https://github.com/dlex/spdlog/releases
I would like to tidy these features up and deliver them upstream. But before starting with that, I would like a feedback from the maintainers if this change is welcome. There is a lot of code to be reviewed, and there are some compatibility implications that, I believe, can be worked on.
Beta Was this translation helpful? Give feedback.
All reactions