Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Memory statistic #817

Merged
merged 5 commits into from
Aug 31, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Main class for memory statistic enabling
  • Loading branch information
KonstantinAnisimov authored and Nikolay Igotti committed Aug 31, 2017
commit 755fe2c7241b7e6827ee45ea8447c8c7dfe22c2d
32 changes: 32 additions & 0 deletions runtime/src/main/cpp/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef RUNTIME_MEMORY_H
#define RUNTIME_MEMORY_H

#include <cstdio>
#include "Assert.h"
#include "Common.h"
#include "TypeInfo.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это лучше в Memory.cpp перенести.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделано

Expand Down Expand Up @@ -405,4 +406,35 @@ class ObjHolder {
ObjHeader* obj_;
};

#define INC_ALLOC_STATISTIC memoryStatistic

class MemoryStatisitic {
public:
long long allocHeapCounter = 0;
long long freeHeapCounter = 0;
long long updateHeapCounter = 0;

long long allocStackCounter = 0;
long long freeStackCounter = 0;
long long updateStackCounter = 0;

void incAlloc(ObjHeader* location) {
ContainerHeader* header = location->container();
switch (header->refCount_ & CONTAINER_TAG_MASK) {
case CONTAINER_TAG_PERMANENT: allocHeapCounter ++; break;
case CONTAINER_TAG_NORMAL : allocHeapCounter ++; break;
case CONTAINER_TAG_STACK : allocStackCounter ++; break;
default: RuntimeAssert(false, "unknown container type");
}
}

MemoryStatisitic() {
fprintf(stderr, "Akm start\n");
}

~MemoryStatisitic() {
fprintf(stderr, "Akm finish\n");
}
};

#endif // RUNTIME_MEMORY_H