Allow options 'ID_STR_HEAPMIN' and 'ID_STR_HEAPMAX' to be set independently.
This commit is contained in:
parent
656d4145c1
commit
2d5b01092b
@ -137,15 +137,15 @@ Some options can be configured via the launcher executable's [STRINGTABLE](https
|
|||||||
|
|
||||||
* **`ID_STR_HEAPMIN` (0x6)**
|
* **`ID_STR_HEAPMIN` (0x6)**
|
||||||
Specifies the the ***minimum*** Java heap size (i.e. JVM option `-Xms`), as percentage of the total physical memory.
|
Specifies the the ***minimum*** Java heap size (i.e. JVM option `-Xms`), as percentage of the total physical memory.
|
||||||
This must be an integral value in the `1` to `100` range, and it must be less than or equal to `ID_STR_HEAPMAX`.
|
This value must be an integral value in the `1` to `100` range.
|
||||||
|
|
||||||
(This option **must** be specified together with `ID_STR_HEAPMAX`)
|
(If `ID_STR_HEAPMAX` is specified too, then this value **must** be less than or equal to `ID_STR_HEAPMAX`).
|
||||||
|
|
||||||
* **`ID_STR_HEAPMAX` (0x7)**
|
* **`ID_STR_HEAPMAX` (0x7)**
|
||||||
Specifies the the ***maximum*** Java heap size (i.e. JVM option `-Xmx`), as percentage of the total physical memory.
|
Specifies the the ***maximum*** Java heap size (i.e. JVM option `-Xmx`), as percentage of the total physical memory.
|
||||||
This must be an integral value in the `1` to `100` range, and it must be greater than or equal to `ID_STR_HEAPMIN`.
|
This value must be an integral value in the `1` to `100` range.
|
||||||
|
|
||||||
(This option **must** be specified together with `ID_STR_HEAPMIN`)
|
(If `ID_STR_HEAPMIN` is specified too, then this value **must** be greater than or equal to `ID_STR_HEAPMIN`).
|
||||||
|
|
||||||
* **`ID_STR_JAVAMIN` (0x8)**
|
* **`ID_STR_JAVAMIN` (0x8)**
|
||||||
Specifies the ***minimum*** supported JRE version, in the **`w.x.y.z`** format (e.g. `11.0.0.0`).
|
Specifies the ***minimum*** supported JRE version, in the **`w.x.y.z`** format (e.g. `11.0.0.0`).
|
||||||
|
45
src/head.c
45
src/head.c
@ -1216,19 +1216,22 @@ static const wchar_t *encode_commandline_str(const wchar_t *const command_line)
|
|||||||
|
|
||||||
const wchar_t *create_heap_size_parameters(const DWORD jvm_heap_percent_min, const DWORD jvm_heap_percent_max, const wchar_t *const jvm_extra_args)
|
const wchar_t *create_heap_size_parameters(const DWORD jvm_heap_percent_min, const DWORD jvm_heap_percent_max, const wchar_t *const jvm_extra_args)
|
||||||
{
|
{
|
||||||
if ((jvm_heap_percent_min > 0U) && (jvm_heap_percent_max >= jvm_heap_percent_min))
|
const ULONGLONG physical_memory_size = get_physical_memory_size();
|
||||||
|
if (physical_memory_size > 0ULL)
|
||||||
{
|
{
|
||||||
const ULONGLONG physical_memory_size = get_physical_memory_size();
|
const DWORD heap_size_mbytes_min = ((jvm_heap_percent_min > 0U) && (jvm_heap_percent_min <= 100U)) ? ((DWORD)((((ULONGLONG)((jvm_heap_percent_min / (double)100U) * physical_memory_size)) + (BYTES_PER_MEGABYTE - 1U)) / BYTES_PER_MEGABYTE)) : 0U;
|
||||||
if (physical_memory_size > 0ULL)
|
const DWORD heap_size_mbytes_max = ((jvm_heap_percent_max > 0U) && (jvm_heap_percent_max <= 100U)) ? ((DWORD)((((ULONGLONG)((jvm_heap_percent_max / (double)100U) * physical_memory_size)) + (BYTES_PER_MEGABYTE - 1U)) / BYTES_PER_MEGABYTE)) : 0U;
|
||||||
|
if ((heap_size_mbytes_min > 0U) && (heap_size_mbytes_max >= heap_size_mbytes_min))
|
||||||
{
|
{
|
||||||
const DWORD heap_size_mbytes_min = (DWORD)((((ULONGLONG)((jvm_heap_percent_min / (double)100U) * physical_memory_size)) + (BYTES_PER_MEGABYTE - 1U)) / BYTES_PER_MEGABYTE);
|
return AVAILABLE(jvm_extra_args)
|
||||||
const DWORD heap_size_mbytes_max = (DWORD)((((ULONGLONG)((jvm_heap_percent_max / (double)100U) * physical_memory_size)) + (BYTES_PER_MEGABYTE - 1U)) / BYTES_PER_MEGABYTE);
|
? aswprintf(L"-Xms%um -Xmx%um %s", heap_size_mbytes_min, heap_size_mbytes_max, jvm_extra_args)
|
||||||
if ((heap_size_mbytes_min > 0U) && (heap_size_mbytes_max >= heap_size_mbytes_min))
|
: aswprintf(L"-Xms%um -Xmx%um", heap_size_mbytes_min, heap_size_mbytes_max);
|
||||||
{
|
}
|
||||||
return AVAILABLE(jvm_extra_args)
|
else if ((heap_size_mbytes_min > 0U) || (heap_size_mbytes_max > 0U))
|
||||||
? aswprintf(L"-Xms%um -Xmx%um %s", heap_size_mbytes_min, heap_size_mbytes_max, jvm_extra_args)
|
{
|
||||||
: aswprintf(L"-Xms%um -Xmx%um", heap_size_mbytes_min, heap_size_mbytes_max);
|
return AVAILABLE(jvm_extra_args)
|
||||||
}
|
? aswprintf(L"-Xm%c%um %s", (heap_size_mbytes_min > 0U) ? L's' : L'x', (heap_size_mbytes_min > 0U) ? heap_size_mbytes_min : heap_size_mbytes_max, jvm_extra_args)
|
||||||
|
: aswprintf(L"-Xm%c%um", (heap_size_mbytes_min > 0U) ? L's' : L'x', (heap_size_mbytes_min > 0U) ? heap_size_mbytes_min : heap_size_mbytes_max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1734,7 +1737,7 @@ static int launch5j_main(const HINSTANCE hinstance, const wchar_t *const cmd_lin
|
|||||||
// Set minimum/maximum Java heap size
|
// Set minimum/maximum Java heap size
|
||||||
jvm_heap_percent_min = bound_value(0U, load_uint32(hinstance, ID_STR_HEAPMIN, 0U), 100U);
|
jvm_heap_percent_min = bound_value(0U, load_uint32(hinstance, ID_STR_HEAPMIN, 0U), 100U);
|
||||||
jvm_heap_percent_max = bound_value(0U, load_uint32(hinstance, ID_STR_HEAPMAX, 0U), 100U);
|
jvm_heap_percent_max = bound_value(0U, load_uint32(hinstance, ID_STR_HEAPMAX, 0U), 100U);
|
||||||
if ((jvm_heap_percent_min != 0U) && (jvm_heap_percent_max != 0U))
|
if ((jvm_heap_percent_min > 0U) || (jvm_heap_percent_max > 0U))
|
||||||
{
|
{
|
||||||
const wchar_t *const jvm_heap_size_args = create_heap_size_parameters(jvm_heap_percent_min, jvm_heap_percent_max, jvm_extra_args);
|
const wchar_t *const jvm_heap_size_args = create_heap_size_parameters(jvm_heap_percent_min, jvm_heap_percent_max, jvm_extra_args);
|
||||||
if (jvm_heap_size_args)
|
if (jvm_heap_size_args)
|
||||||
@ -1832,7 +1835,9 @@ cleanup:
|
|||||||
/* Entry points */
|
/* Entry points */
|
||||||
/* ======================================================================== */
|
/* ======================================================================== */
|
||||||
|
|
||||||
#define THE_NUMBER_OF_THE_BEAST 666
|
extern IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
extern LPWSTR _wcmdln;
|
||||||
|
#define UNHANDELED_EXCEPTION_ERROR 666
|
||||||
|
|
||||||
static LONG WINAPI unhandeled_exception(EXCEPTION_POINTERS *ExceptionInfo)
|
static LONG WINAPI unhandeled_exception(EXCEPTION_POINTERS *ExceptionInfo)
|
||||||
{
|
{
|
||||||
@ -1843,22 +1848,23 @@ static LONG WINAPI unhandeled_exception(EXCEPTION_POINTERS *ExceptionInfo)
|
|||||||
DWORD chars_written;
|
DWORD chars_written;
|
||||||
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), ERROR_MESSAGE, lstrlenW(ERROR_MESSAGE), &chars_written, NULL);
|
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), ERROR_MESSAGE, lstrlenW(ERROR_MESSAGE), &chars_written, NULL);
|
||||||
#endif
|
#endif
|
||||||
TerminateProcess(GetCurrentProcess(), THE_NUMBER_OF_THE_BEAST);
|
TerminateProcess(GetCurrentProcess(), UNHANDELED_EXCEPTION_ERROR);
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if L5J_ENABLE_GUI
|
#if L5J_ENABLE_GUI
|
||||||
|
|
||||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||||
SetUnhandledExceptionFilter(unhandeled_exception);
|
SetUnhandledExceptionFilter(unhandeled_exception);
|
||||||
#endif
|
#endif
|
||||||
return launch5j_main(hInstance, pCmdLine);
|
return launch5j_main(hInstance, get_commandline_args(_wcmdln));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
extern IMAGE_DOS_HEADER __ImageBase;
|
#else /*L5J_ENABLE_GUI*/
|
||||||
extern LPWSTR _wcmdln;
|
|
||||||
int wmain(int argc, wchar_t **argv, wchar_t **envp)
|
int wmain(int argc, wchar_t **argv, wchar_t **envp)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
@ -1868,4 +1874,5 @@ int wmain(int argc, wchar_t **argv, wchar_t **envp)
|
|||||||
_setmode(_fileno(stderr), _O_U8TEXT);
|
_setmode(_fileno(stderr), _O_U8TEXT);
|
||||||
return launch5j_main((HINSTANCE) &__ImageBase, get_commandline_args(_wcmdln));
|
return launch5j_main((HINSTANCE) &__ImageBase, get_commandline_args(_wcmdln));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#endif /*L5J_ENABLE_GUI*/
|
||||||
|
Loading…
Reference in New Issue
Block a user