ATLAS Offline Software
Loading...
Searching...
No Matches
MonitoredMemoryResource.h
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3//
4#ifndef ATHDEVICECOMPS_MONITOREDMEMORYRESOURCE_H
5#define ATHDEVICECOMPS_MONITOREDMEMORYRESOURCE_H
6
7// AthDevice include(s).
9
10// System include(s).
11#include <functional>
12#include <memory_resource>
13
14namespace AthDevice {
15
22class MonitoredMemoryResource : public std::pmr::memory_resource {
23
24 public:
26 MonitoredMemoryResource(std::pmr::memory_resource& upstream,
27 IMemoryMonitorSvc& svc, const std::string& component,
28 const std::string& device);
31
32 private:
35
37 virtual void* do_allocate(std::size_t bytes, std::size_t alignment) override;
38
40 virtual void do_deallocate(void* p, std::size_t bytes,
41 std::size_t alignment) override;
42
44 virtual bool do_is_equal(
45 const std::pmr::memory_resource& other) const noexcept override;
46
48
51
53 std::reference_wrapper<std::pmr::memory_resource> m_upstream;
55 std::reference_wrapper<IMemoryMonitorSvc> m_svc;
57 std::string m_component;
59 std::string m_device;
60
62
63}; // class MonitoredMemoryResource
64
65} // namespace AthDevice
66
67#endif // ATHDEVICECOMPS_MONITOREDMEMORYRESOURCE_H
Interface to a service that provides "device memory monitoring".
virtual ~MonitoredMemoryResource()
Destructor.
virtual void * do_allocate(std::size_t bytes, std::size_t alignment) override
Allocate memory from the resource.
std::reference_wrapper< std::pmr::memory_resource > m_upstream
The upstream memory resource to which the allocations are forwarded.
std::string m_device
The name of the device for which the memory resource is provided.
virtual bool do_is_equal(const std::pmr::memory_resource &other) const noexcept override
Check if the resource is equal to another resource.
std::reference_wrapper< IMemoryMonitorSvc > m_svc
The service used to monitor the memory allocations/deallocations.
std::string m_component
The name of the component that is using this memory resource.
virtual void do_deallocate(void *p, std::size_t bytes, std::size_t alignment) override
Deallocate memory from the resource.
MonitoredMemoryResource(std::pmr::memory_resource &upstream, IMemoryMonitorSvc &svc, const std::string &component, const std::string &device)
Constructor.