/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "memory/allocation.hpp"
#include "services/memPtr.hpp"
#include "services/memSnapshot.hpp"
// compare unsigned number
/*
* MallocCallsitePointer and VMCallsitePointer are used
* to baseline memory blocks with their callsite information.
* They are only available when detail tracking is turned
* on.
*/
/* baselined malloc record aggregated by callsite */
private:
public:
_count = 0;
_amount = 0;
}
_count = 0;
_amount = 0;
}
MallocCallsitePointer& operator=(const MallocCallsitePointer& p) {
MemPointer::operator=(p);
return *this;
}
_count ++;
};
return _count;
}
return _amount;
}
};
// baselined virtual memory record aggregated by callsite
private:
public:
_count = 0;
_reserved_amount = 0;
_committed_amount = 0;
}
_count = 0;
_reserved_amount = 0;
_committed_amount = 0;
}
VMCallsitePointer& operator=(const VMCallsitePointer& p) {
MemPointer::operator=(p);
_reserved_amount = p.reserved_amount();
return *this;
}
_count ++;
}
return _count;
}
return _reserved_amount;
}
return _committed_amount;
}
};
// maps a memory type flag to readable name
typedef struct _memType2Name {
const char* _name;
} MemType2Name;
// This class aggregates malloc'd records by memory type
private:
public:
MallocMem() {
_count = 0;
_amount = 0;
}
_count = 0;
_amount = 0;
}
}
inline void clear() {
_count = 0;
_amount = 0;
}
return *this;
}
_count ++;
}
}
}
return _type;
}
}
return _count;
}
return _amount;
}
};
// This class records live arena's memory usage
public:
}
ArenaMem() { }
};
// This class aggregates virtual memory by its memory type
private:
public:
VMMem() {
_count = 0;
_reserved_amount = 0;
_committed_amount = 0;
}
_count = 0;
_reserved_amount = 0;
_committed_amount = 0;
}
inline void clear() {
_count = 0;
_reserved_amount = 0;
_committed_amount = 0;
}
}
_reserved_amount = m.reserved_amount();
return *this;
}
return _type;
}
}
_count ++;
}
return _count;
}
return _reserved_amount;
}
return _committed_amount;
}
};
class BaselineReporter;
class BaselineComparisonReporter;
/*
* This class baselines current memory snapshot.
* A memory baseline summarizes memory usage by memory type,
* aggregates memory usage by callsites when detail tracking
* is on.
*/
friend class BaselineReporter;
friend class BaselineComparisonReporter;
private:
// overall summaries
// if it has properly baselined
bool _baselined;
// we categorize memory into three categories within the memory type
// memory records that aggregate memory usage by callsites.
// only available when detail tracking is on.
// virtual memory map
private:
private:
// should not use copy constructor
// check and block at a safepoint
public:
// create a memory baseline
MemBaseline();
virtual ~MemBaseline();
inline bool baselined() const {
return _baselined;
}
// reset the baseline for reuse
void clear();
// baseline the snapshot
const MemPointerArray* vm_records,
bool summary_only = true);
// total malloc'd memory of specified memory type
}
// number of malloc'd memory blocks of specified memory type
}
// total memory used by arenas of specified memory type
}
// number of arenas of specified memory type
}
// total reserved memory of specified memory type
}
// total committed memory of specified memory type
}
// total memory (malloc'd + mmap'd + arena) of specified
// memory type
}
/* overall summaries */
// total malloc'd memory in snapshot
return _total_malloced;
}
// total mmap'd memory in snapshot
return _total_vm_reserved;
}
// total committed memory in snapshot
return _total_vm_committed;
}
// number of loaded classes
return _number_of_classes;
}
// number of running threads
return _number_of_threads;
}
// lookup human readable name of a memory type
private:
// convert memory flag to the index to mapping table
// reset baseline values
void reset();
// summarize the records in global snapshot
// print a line of malloc'd memory aggregated by callsite
// print a line of mmap'd memory aggregated by callsite
// sorting functions for raw records
private:
// sorting functions for baselined records
};
#endif // SHARE_VM_SERVICES_MEM_BASELINE_HPP