Home » Community » U++ community news and announcements » Core 2019
Re: Core 2019 [message #51857 is a reply to message #51856] |
Sun, 09 June 2019 23:25 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Here is the code for logging all huge allocations (replace in Core/hheap.cpp):
void *Heap::HugeAlloc(size_t count) // count in 4kb pages
{
ASSERT(count);
#ifdef LSTAT
if(count < 65536)
hstat[count]++;
#endif
huge_4KB_count += count;
if(huge_4KB_count > huge_4KB_count_max) {
huge_4KB_count_max = huge_4KB_count;
if(MemoryUsedKb() > sKBLimit)
Panic("MemoryLimitKb breached!");
if(sPeak)
Make(*sPeak);
}
if(!D::freelist[0]->next) { // initialization
for(int i = 0; i < 2; i++)
Dbl_Self(D::freelist[i]);
}
if(count > HPAGE) { // we are wasting 4KB to store just 4 bytes here, but this is >32MB after all..
LTIMING("SysAlloc");
byte *sysblk = (byte *)SysAllocRaw((count + 1) * 4096, 0);
BlkHeader *h = (BlkHeader *)(sysblk + 4096);
h->size = 0;
*((size_t *)sysblk) = count;
sys_count++;
sys_size += 4096 * count;
return h;
}
LTIMING("Huge Alloc");
word wcount = (word)count;
if(16 * free_4KB > huge_4KB_count) // keep number of free 4KB blocks in check
FreeSmallEmpty(INT_MAX, int(free_4KB - huge_4KB_count / 32));
for(int pass = 0; pass < 2; pass++) {
for(int i = count >= 16; i < 2; i++) {
BlkHeader *l = D::freelist[i];
BlkHeader *h = l->next;
while(h != l) {
word sz = h->GetSize();
if(sz >= count) {
void *ptr = MakeAlloc(h, wcount);
if(count > 16)
RLOG("HugeAlloc " << asString(ptr) << ", size: " << asString(count));
return ptr;
}
h = h->next;
}
}
if(!FreeSmallEmpty(wcount, INT_MAX)) { // try to coalesce 4KB small free blocks back to huge storage
void *ptr = SysAllocRaw(HPAGE * 4096, 0);
HugePage *pg = (HugePage *)MemoryAllocPermanent(sizeof(HugePage));
pg->page = ptr;
pg->next = huge_pages;
huge_pages = pg;
AddChunk((BlkHeader *)ptr, HPAGE); // failed, add 32MB from the system
huge_chunks++;
}
}
Panic("Out of memory");
return NULL;
}
int Heap::HugeFree(void *ptr)
{
BlkHeader *h = (BlkHeader *)ptr;
if(h->size == 0) {
LTIMING("Sys Free");
byte *sysblk = (byte *)h - 4096;
size_t count = *((size_t *)sysblk);
SysFreeRaw(sysblk, (count + 1) * 4096);
huge_4KB_count -= count;
sys_count--;
sys_size -= 4096 * count;
return 0;
}
LTIMING("Huge Free");
if(h->GetSize() > 16)
RLOG("HugeFree " << asString(ptr) << ", size: " << asString(h->GetSize()));
huge_4KB_count -= h->GetSize();
return BlkHeap::Free(h)->GetSize();
}
bool Heap::HugeTryRealloc(void *ptr, size_t count)
{
bool b = count <= HPAGE && BlkHeap::TryRealloc(ptr, count, huge_4KB_count);
if(b)
RLOG("HugeRealloc " << asString(ptr) << ", size: " << asString(count));
return b;
}
(please test with active MemoryTryRealloc)
[Updated on: Sun, 09 June 2019 23:25] Report message to a moderator
|
|
|
|
|
Core 2019
By: mirek on Fri, 07 June 2019 13:56
|
|
|
Re: Core 2019
By: Novo on Fri, 07 June 2019 17:51
|
|
|
Re: Core 2019
By: mirek on Fri, 07 June 2019 18:01
|
|
|
Re: Core 2019
By: Novo on Fri, 07 June 2019 23:00
|
|
|
Re: Core 2019
By: Novo on Sat, 08 June 2019 18:30
|
|
|
Re: Core 2019
By: mirek on Sat, 08 June 2019 18:40
|
|
|
Re: Core 2019
By: Novo on Sat, 08 June 2019 19:44
|
|
|
Re: Core 2019
By: mirek on Sat, 08 June 2019 20:38
|
|
|
Re: Core 2019
By: Novo on Sat, 08 June 2019 21:45
|
|
|
Re: Core 2019
By: Novo on Sat, 08 June 2019 21:42
|
|
|
Re: Core 2019
By: mirek on Sat, 08 June 2019 18:31
|
|
|
Re: Core 2019
By: Novo on Sat, 08 June 2019 21:54
|
|
|
Re: Core 2019
By: Novo on Sat, 08 June 2019 22:06
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 10:03
|
|
|
Re: Core 2019
By: Novo on Sun, 09 June 2019 15:20
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 16:33
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 16:43
|
|
|
Re: Core 2019
By: Novo on Sun, 09 June 2019 17:34
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 18:54
|
|
|
Re: Core 2019
By: Novo on Sun, 09 June 2019 21:39
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 23:11
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 23:25
|
|
|
Re: Core 2019
By: mirek on Mon, 10 June 2019 17:27
|
|
|
Re: Core 2019
By: Novo on Mon, 10 June 2019 18:01
|
|
|
Re: Core 2019
By: mirek on Mon, 10 June 2019 18:17
|
|
|
Re: Core 2019
By: Novo on Mon, 10 June 2019 18:21
|
|
|
Re: Core 2019
By: Novo on Mon, 10 June 2019 18:45
|
|
|
Re: Core 2019
By: Novo on Mon, 10 June 2019 18:18
|
|
|
Re: Core 2019
By: Novo on Mon, 10 June 2019 18:34
|
|
|
Re: Core 2019
By: Novo on Sun, 09 June 2019 17:02
|
|
|
Re: Core 2019
By: Novo on Sun, 09 June 2019 17:15
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 20:56
|
|
|
Re: Core 2019
By: mirek on Sun, 09 June 2019 18:51
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 05:43
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 06:14
|
|
|
Re: Core 2019
By: mirek on Fri, 21 June 2019 09:16
|
|
|
Re: Core 2019
By: mirek on Fri, 21 June 2019 09:23
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 19:58
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 20:28
|
|
|
Re: Core 2019
By: Novo on Sat, 22 June 2019 02:51
|
|
|
Re: Core 2019
By: Novo on Sat, 22 June 2019 02:53
|
|
|
Re: Core 2019
By: mirek on Sat, 22 June 2019 10:23
|
|
|
Re: Core 2019
By: Novo on Sat, 22 June 2019 17:49
|
|
|
Re: Core 2019
By: mirek on Sat, 22 June 2019 22:22
|
|
|
Re: Core 2019
By: Novo on Sat, 22 June 2019 23:44
|
|
|
Re: Core 2019
By: mirek on Sun, 23 June 2019 08:21
|
|
|
Re: Core 2019
By: Novo on Sun, 23 June 2019 21:26
|
|
|
Re: Core 2019
By: mirek on Mon, 24 June 2019 09:22
|
|
|
Re: Core 2019
By: Novo on Mon, 24 June 2019 17:36
|
|
|
Re: Core 2019
By: mirek on Mon, 24 June 2019 18:42
|
|
|
Re: Core 2019
By: Novo on Mon, 24 June 2019 19:36
|
|
|
Re: Core 2019
By: mirek on Mon, 24 June 2019 20:15
|
|
|
Re: Core 2019
By: mirek on Sun, 23 June 2019 09:55
|
|
|
Re: Core 2019
By: mirek on Sun, 23 June 2019 10:19
|
|
|
Re: Core 2019
By: Novo on Mon, 24 June 2019 06:13
|
|
|
Re: Core 2019
By: mirek on Wed, 26 June 2019 08:52
|
|
|
Re: Core 2019
By: mirek on Thu, 27 June 2019 09:44
|
|
|
Re: Core 2019
By: mirek on Fri, 28 June 2019 09:09
|
|
|
Re: Core 2019
By: Tom1 on Fri, 28 June 2019 16:56
|
|
|
Re: Core 2019
By: mirek on Fri, 28 June 2019 17:30
|
|
|
Re: Core 2019
By: mirek on Fri, 28 June 2019 17:31
|
|
|
Re: Core 2019
By: mirek on Fri, 28 June 2019 17:40
|
|
|
Re: Core 2019
By: Tom1 on Fri, 28 June 2019 18:38
|
|
|
Re: Core 2019
By: Novo on Sun, 30 June 2019 19:02
|
|
|
Re: Core 2019
By: mirek on Sun, 30 June 2019 19:11
|
|
|
Re: Core 2019
By: Novo on Sun, 30 June 2019 20:12
|
|
|
Re: Core 2019
By: mirek on Mon, 01 July 2019 00:03
|
|
|
Re: Core 2019
By: Tom1 on Mon, 01 July 2019 09:14
|
|
|
Re: Core 2019
By: Novo on Thu, 11 July 2019 19:55
|
|
|
Re: Core 2019
By: mirek on Thu, 11 July 2019 20:14
|
|
|
Re: Core 2019
By: Novo on Thu, 11 July 2019 20:53
|
|
|
Re: Core 2019
By: mirek on Fri, 12 July 2019 10:09
|
|
|
Re: Core 2019
By: Novo on Fri, 12 July 2019 16:50
|
|
|
Re: Core 2019
By: Novo on Thu, 08 August 2019 21:47
|
|
|
Re: Core 2019
By: mirek on Thu, 08 August 2019 22:47
|
|
|
Re: Core 2019
By: mirek on Thu, 08 August 2019 22:53
|
|
|
Re: Core 2019
By: mirek on Thu, 08 August 2019 22:59
|
|
|
Re: Core 2019
By: Novo on Thu, 08 August 2019 23:30
|
|
|
Re: Core 2019
By: mirek on Fri, 09 August 2019 00:05
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 17:59
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 18:01
|
|
|
Re: Core 2019
By: Novo on Fri, 21 June 2019 18:10
|
Goto Forum:
Current Time: Fri Apr 26 17:49:25 CEST 2024
Total time taken to generate the page: 0.04471 seconds
|