45 #ifndef Included_MemorySegment
46 #define Included_MemorySegment
52 #define MemorySegmentOverhead (sizeof(MemorySegmentHeader))
53 #define MemorySegmentPoolOverhead (sizeof(MemorySegmentPoolHeader))
57 #define SegmentSize (256*1024*2)
59 #define LargeBlockThreshold 8192
62 #define SegmentSize (256*1024)
64 #define LargeBlockThreshold 4096
67 #define MinimumSegmentSize (SegmentSize/2)
69 #define MinimumSegmentDeadSpace (MinimumSegmentSize - MemorySegmentOverhead)
71 #define LargeSegmentSize (SegmentSize * 4)
73 #define SegmentDeadSpace (SegmentSize - MemorySegmentOverhead)
75 #define RecoverSegmentSize ((SegmentSize/2) - MemorySegmentOverhead)
77 #define LargeSegmentDeadSpace (LargeSegmentSize - MemorySegmentOverhead)
79 #define InitialNormalSegmentSpace ((LargeSegmentSize * 8) - MemorySegmentOverhead)
81 #define LargestNormalSegmentSize (LargeObjectMinSize - (1024 * 1024) - MemorySegmentOverhead)
87 #define MemoryThrashingThreshold 4
91 #define LengthToDeadPool(l) ((l)/ObjectGrain)
94 #define DeadPoolToLength(d) ((d)*ObjectGrain)
99 #define FirstDeadPool (LengthToDeadPool(MinimumObjectSize) - 1)
101 #define LargestSubpool 512
103 #define LastDeadPool LengthToDeadPool(LargestSubpool)
106 #define DeadPools LastDeadPool + 1
109 #define NormalMemoryExpansionThreshold .30
111 #define NormalMemoryContractionThreshold .70
115 #define MaxDeadObjectSpace 1000000
151 inline void *
operator new(
size_t size,
void *segment) {
return segment; }
152 inline void operator delete(
void *) { }
153 inline void operator delete(
void *,
void *) { }
201 inline bool isLastBlock(
char *addr,
size_t length) {
return (addr + length) ==
end(); }
210 void dump(
const char *owner,
size_t counter, FILE *keyfile, FILE *dumpfile);
240 this->
name = setName;
252 inline void *
operator new(
size_t size,
void *segment) {
return segment; }
253 inline void operator delete(
void * size) { }
254 inline void operator delete(
void * size,
void *segment) { }
289 return segment->
next;
298 while (segment != NULL) {
302 segment =
next(segment);
339 bool newSegment(
size_t requestLength,
size_t minimumLength);
457 if (newObject != NULL) {
458 size_t deadLength = realLength - allocationLength;
528 ((
RexxObject *)
object)->setObjectSize(allocationLength);
558 if (largeObject != NULL) {
#define LengthToDeadPool(l)
#define NormalMemoryExpansionThreshold
#define MemorySegmentOverhead
size_t roundSegmentBoundary(size_t n)
#define NormalMemoryContractionThreshold
#define LargeAllocationUnit
#define MinimumObjectSize
void add(DeadObject *obj)
DeadObject * findBestFit(size_t length)
void addSingle(DeadObject *obj)
DeadObject * findFit(size_t length)
DeadObject * getFirstSingle()
RexxObject * findObject(size_t allocationLength)
virtual void prepareForSweep()
RexxObject * allocateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
virtual ~LargeSegmentSet()
virtual DeadObject * donateObject(size_t allocationLength)
RexxObject * handleAllocationFailure(size_t allocationLength)
virtual MemorySegment * allocateSegment(size_t requestLength, size_t minimumLength)
void expandOrCollect(size_t allocationLength)
void expandSegmentSet(size_t allocationLength)
void completeSweepOperation()
virtual void addDeadObject(DeadObject *object)
bool isInSegment(RexxObject *object)
void gatherObjectStats(MemoryStats *memStats, SegmentStats *stats)
bool isFirstBlock(char *addr)
bool isLastBlock(char *addr, size_t length)
void shrink(size_t delta)
void combine(MemorySegment *nextSegment)
DeadObject * lastDeadObject()
void insertAfter(MemorySegment *newSegment)
DeadObject * firstDeadObject()
void dump(const char *owner, size_t counter, FILE *keyfile, FILE *dumpfile)
DeadObject * createDeadObject()
bool isAdjacentTo(MemorySegment *seg)
DeadObject * firstObject()
friend class OldSegmentSet
void insertBefore(MemorySegment *newSegment)
MemorySegment(size_t segSize)
void dumpSegments(FILE *keyfile, FILE *dumpfile)
void activateEmptySegments()
bool isInSegmentSet(RexxObject *object)
MemorySegment * findEmptySegment(size_t allocationLength)
void addSegment(MemorySegment *segment, bool createDeadObject=1)
void removeSegmentAndStorage(MemorySegment *segment)
MemorySegmentSet(RexxMemory *memObject, SegmentSetID id, const char *setName)
virtual size_t suggestMemoryContraction()
size_t calculateSegmentAllocation(size_t n)
void releaseEmptySegments(size_t releaseSize)
MemorySegment emptySegments
RexxObject * splitDeadObject(DeadObject *object, size_t allocationLength, size_t splitMinimum)
void mergeSegments(size_t allocationLength)
MemorySegment * largestEmptySegment()
void combineEmptySegments(MemorySegment *front, MemorySegment *back)
void addSegments(size_t requiredSpace)
virtual MemorySegment * allocateSegment(size_t requestLength, size_t minimumLength)
virtual void completeSweepOperation()
virtual size_t suggestMemoryExpansion()
void releaseSegment(MemorySegment *segment)
virtual void prepareForSweep()
virtual void collectEmptySegments()
MemorySegment * getSegment(size_t requestLength, size_t minimumLength)
virtual ~MemorySegmentSet()
float freeMemoryPercentage()
void insertSegment(MemorySegment *segment)
void gatherStats(MemoryStats *memStats, SegmentStats *stats)
MemorySegment * splitSegment(size_t allocationLength)
void removeSegment(MemorySegment *segment)
virtual DeadObject * donateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
void add(MemorySegment *segment)
MemorySegment * next(MemorySegment *segment)
bool newSegment(size_t requestLength, size_t minimumLength)
void validateObject(size_t bytes)
MemorySegment * largestActiveSegment()
virtual MemorySegment * donateSegment(size_t allocationLength)
virtual void addDeadObject(DeadObject *object)
size_t recommendedMaximumMemorySize()
virtual void addDeadObject(DeadObject *object)
virtual size_t suggestMemoryContraction()
RexxObject * findObject(size_t allocationLength)
MemorySegment * recoverSegment
RexxObject * splitNormalDeadObject(DeadObject *object, size_t allocationLength, size_t deadLength)
virtual DeadObject * donateObject(size_t allocationLength)
virtual void dumpMemoryProfile(FILE *outfile)
DeadObjectPool subpools[DeadPools]
virtual void prepareForSweep()
RexxObject * handleAllocationFailure(size_t allocationLength)
RexxObject * findLargeDeadObject(size_t allocationLength)
void completeSweepOperation()
void checkObjectOverlap(DeadObject *obj)
size_t lastUsedSubpool[DeadPools+1]
size_t mapLengthToDeadPool(size_t length)
size_t recommendedMemorySize()
virtual ~NormalSegmentSet()
virtual size_t suggestMemoryExpansion()
RexxObject * allocateObject(size_t allocationLength)
RexxObject * allocateObject(size_t allocationLength)
virtual ~OldSpaceSegmentSet()
virtual void addDeadObject(DeadObject *object)
RexxObject * findObject(size_t allocationLength)
void markOldSpaceObjects()
MemorySegment * newSegment(size_t requestLength, size_t minLength)