-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemoryManagerClass.h
75 lines (66 loc) · 1.99 KB
/
MemoryManagerClass.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#ifndef MEMORYMANAGERCLASS_H
#define MEMORYMANAGERCLASS_H
#include <string.h>
#include "BaseTypes.h"
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include "TimerClass.h"
using namespace std;
typedef struct
{
unsigned int Start;
unsigned int Length;
void* Address;
}TMemoryArea;
class MemoryManagerClass
{
public:
bool _UseSelfMemoryManagement;
MemoryManagerClass(unsigned int SegmentSize, bool AutomaticReleaseSegment, bool InitializeMems);
MemoryManagerClass(bool InitializeMems);
void* AllocVoid(int ElementNumber, int ElementSize);
short* AllocShort(int ElementNumber);
char* AllocChar(int ElementNumber);
int* AllocInt(int ElementNumber);
double* AllocDouble(int ElementNumber);
float* AllocFloat(int ElementNumber);
Complex64* AllocComplex64(int ElementNumber);
Complex32* AllocComplex32(int ElementNumber);
ComplexInt* AllocComplexInt(int ElementNumber);
ComplexShort* AllocComplexShort(int ElementNumber);
void FREEMEM(void** MemAdd);
void Distroy();
__int64 GetTotalAllocationTime();
__int64 GetTotalAllocationSize();
void ResetManager(int KeepSegmentCount);
int GetAllocationCount();
int GetReleaseCount();
int GetUnReleaseCount();
int GetMaxAllocationSize();
private:
int _Max_Allocation_Size;
int _Allocation_Count;
int _Release_Count;
int _UnReleased_Count;
void** _Mem;
bool _Automatic_Release_Segment;
int _Current_Segment;
int _Max_Segment_Count;
unsigned int _Start;
unsigned int _Segment_Size;
__int64 _Total_Allocation_Size;
__int64 _Total_Allocation_Time;
char LogFileName[200];
bool _InitializeMems;
vector<string> _MemTag;
vector< vector<TMemoryArea>> _In_Use_Memory_Locations;
void* AssignAddressFromIntrnalMem(unsigned int ByteSize, int ElementSize);
void RemoveMemAreaFromList(void* MemAddress);
void* MyAlloc(unsigned int ByteSize, int ElementSize);
void FreeSegment(int SegmentIndex);
void WriteErrorToLogFile(char* txt);
void InitVariables();
};
#endif