aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils/LeakChecking.cpp
blob: ac12fe01defc2a9913ed5576cacdc3a7051bb92c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// See LICENSE file in the project root for full license information.
//

#ifdef ARMNN_LEAK_CHECKING_ENABLED

#include "LeakChecking.hpp"
#include "gperftools/heap-checker.h"

struct ScopedLeakChecker::Impl
{
    HeapLeakChecker m_LeakChecker;

    Impl(const std::string & name)
    : m_LeakChecker(name.c_str())
    {
    }
};

ScopedLeakChecker::ScopedLeakChecker(const std::string & name)
: m_Impl(new Impl(name))
{
}

ScopedLeakChecker::~ScopedLeakChecker() {}

bool ScopedLeakChecker::IsActive()
{
    return HeapLeakChecker::IsActive();
}

bool ScopedLeakChecker::NoLeaks()
{
    return (IsActive() ? m_Impl->m_LeakChecker.NoLeaks() : true);
}

ssize_t ScopedLeakChecker::BytesLeaked() const
{
    return (IsActive() ? m_Impl->m_LeakChecker.BytesLeaked(): 0);
}

ssize_t ScopedLeakChecker::ObjectsLeaked() const
{
    return (IsActive() ? m_Impl->m_LeakChecker.ObjectsLeaked(): 0 );
}

struct ScopedDisableLeakChecking::Impl
{
    HeapLeakChecker::Disabler m_Disabler;
};

ScopedDisableLeakChecking::ScopedDisableLeakChecking()
: m_Impl(new Impl)
{
}

ScopedDisableLeakChecking::~ScopedDisableLeakChecking()
{
}

#endif // ARMNN_LEAK_CHECKING_ENABLED