* heap.cc (eval_initial_heap_size): New function fetching the heap
size from the LoaderFlags field in the PE/COFF header. (heap_init): Call eval_initial_heap_size rather than cygwin_shared->heap_chunk_size to fetch the initial heap size. * shared.cc (shared_info::heap_chunk_size): Remove. * shared_info.h (class shared_info): Drop heap_chunk member. (CURR_SHARED_MAGIC): Update.
This commit is contained in:
parent
c29da54058
commit
afe817741c
|
@ -1,3 +1,13 @@
|
||||||
|
2011-08-09 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* heap.cc (eval_initial_heap_size): New function fetching the heap
|
||||||
|
size from the LoaderFlags field in the PE/COFF header.
|
||||||
|
(heap_init): Call eval_initial_heap_size rather than
|
||||||
|
cygwin_shared->heap_chunk_size to fetch the initial heap size.
|
||||||
|
* shared.cc (shared_info::heap_chunk_size): Remove.
|
||||||
|
* shared_info.h (class shared_info): Drop heap_chunk member.
|
||||||
|
(CURR_SHARED_MAGIC): Update.
|
||||||
|
|
||||||
2011-08-09 Corinna Vinschen <corinna@vinschen.de>
|
2011-08-09 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* ntdll.h (STATUS_NOT_FOUND): Define.
|
* ntdll.h (STATUS_NOT_FOUND): Define.
|
||||||
|
|
|
@ -56,6 +56,30 @@ eval_start_address ()
|
||||||
return start_address;
|
return start_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned
|
||||||
|
eval_initial_heap_size ()
|
||||||
|
{
|
||||||
|
PIMAGE_DOS_HEADER dosheader;
|
||||||
|
PIMAGE_NT_HEADERS32 ntheader;
|
||||||
|
unsigned size;
|
||||||
|
|
||||||
|
dosheader = (PIMAGE_DOS_HEADER) GetModuleHandle (NULL);
|
||||||
|
ntheader = (PIMAGE_NT_HEADERS32) ((PBYTE) dosheader + dosheader->e_lfanew);
|
||||||
|
/* LoaderFlags is an obsolete DWORD member of the PE/COFF file header.
|
||||||
|
It's value is ignored by the loader, so we're free to use it for
|
||||||
|
Cygwin. If it's 0, we default to the usual 384 Megs. Otherwise,
|
||||||
|
we use it as the default initial heap size in megabyte. Valid values
|
||||||
|
are between 4 and 2048 Megs. */
|
||||||
|
size = ntheader->OptionalHeader.LoaderFlags;
|
||||||
|
if (size == 0)
|
||||||
|
size = 384;
|
||||||
|
else if (size < 4)
|
||||||
|
size = 4;
|
||||||
|
else if (size > 2048)
|
||||||
|
size = 2048;
|
||||||
|
return size << 20;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the heap at process start up. */
|
/* Initialize the heap at process start up. */
|
||||||
void
|
void
|
||||||
heap_init ()
|
heap_init ()
|
||||||
|
@ -73,7 +97,7 @@ heap_init ()
|
||||||
SIZE_T ret;
|
SIZE_T ret;
|
||||||
MEMORY_BASIC_INFORMATION mbi;
|
MEMORY_BASIC_INFORMATION mbi;
|
||||||
|
|
||||||
cygheap->user_heap.chunk = cygwin_shared->heap_chunk_size ();
|
cygheap->user_heap.chunk = eval_initial_heap_size ();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
cygheap->user_heap.base = VirtualAlloc ((LPVOID) start_address,
|
cygheap->user_heap.base = VirtualAlloc ((LPVOID) start_address,
|
||||||
|
|
|
@ -444,34 +444,3 @@ memory_init (bool init_cygheap)
|
||||||
shared_info::create (); /* Initialize global shared memory */
|
shared_info::create (); /* Initialize global shared memory */
|
||||||
user_info::create (false); /* Initialize per-user shared memory */
|
user_info::create (false); /* Initialize per-user shared memory */
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
|
||||||
shared_info::heap_chunk_size ()
|
|
||||||
{
|
|
||||||
if (!heap_chunk)
|
|
||||||
{
|
|
||||||
/* Fetch from registry, first user then local machine. */
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
reg_key reg (i, KEY_READ, NULL);
|
|
||||||
|
|
||||||
/* Note that reserving a huge amount of heap space does not result in
|
|
||||||
the use of swap since we are not committing it. */
|
|
||||||
/* FIXME: We should not be restricted to a fixed size heap no matter
|
|
||||||
what the fixed size is. */
|
|
||||||
|
|
||||||
if ((heap_chunk = reg.get_dword (L"heap_chunk_in_mb", 0)))
|
|
||||||
break;
|
|
||||||
heap_chunk = 384; /* Default */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (heap_chunk < 4)
|
|
||||||
heap_chunk = 4 * 1024 * 1024;
|
|
||||||
else
|
|
||||||
heap_chunk <<= 20;
|
|
||||||
if (!heap_chunk)
|
|
||||||
heap_chunk = 384 * 1024 * 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
return heap_chunk;
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
/* Data accessible to all tasks */
|
/* Data accessible to all tasks */
|
||||||
|
|
||||||
|
|
||||||
#define CURR_SHARED_MAGIC 0x34e5bfa7U
|
#define CURR_SHARED_MAGIC 0x8fe4d9eeU
|
||||||
|
|
||||||
#define USER_VERSION 1
|
#define USER_VERSION 1
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ class shared_info
|
||||||
LONG version;
|
LONG version;
|
||||||
DWORD cb;
|
DWORD cb;
|
||||||
public:
|
public:
|
||||||
DWORD heap_chunk;
|
|
||||||
tty_list tty;
|
tty_list tty;
|
||||||
LONG last_used_bindresvport;
|
LONG last_used_bindresvport;
|
||||||
DWORD obcaseinsensitive;
|
DWORD obcaseinsensitive;
|
||||||
|
|
Loading…
Reference in New Issue