1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_MemoryInfo_h
8 #define mozilla_MemoryInfo_h
12 #include "mozilla/Attributes.h"
13 #include "mozilla/EnumSet.h"
15 * MemoryInfo is a helper class which describes the attributes and sizes of a
16 * particular region of VM memory on Windows. It roughtly corresponds to the
17 * values in a MEMORY_BASIC_INFORMATION struct, summed over an entire region or
23 class MemoryInfo final
{
25 enum class Perm
: uint8_t {
34 enum class PageType
: uint8_t {
40 using PermSet
= EnumSet
<Perm
>;
41 using PageTypeSet
= EnumSet
<PageType
>;
43 MemoryInfo() = default;
44 MOZ_IMPLICIT
MemoryInfo(const MemoryInfo
&) = default;
46 uintptr_t Start() const { return mStart
; }
47 uintptr_t End() const { return mEnd
; }
49 PageTypeSet
Type() const { return mType
; }
50 PermSet
Perms() const { return mPerms
; }
52 size_t Reserved() const { return mReserved
; }
53 size_t Committed() const { return mCommitted
; }
54 size_t Free() const { return mFree
; }
55 size_t Size() const { return mSize
; }
57 // Returns a MemoryInfo object containing the sums of all region sizes,
58 // divided into Reserved, Committed, and Free, depending on their State
61 // The entire range of aSize bytes starting at aPtr must correspond to a
62 // single allocation. This restriction is enforced in debug builds.
63 static MemoryInfo
Get(const void* aPtr
, size_t aSize
);
70 size_t mCommitted
= 0;
79 } // namespace mozilla
81 #endif // mozilla_MemoryInfo_h