713 JLI_Snprintf(envName, pbuflen, "%s%d", NMT_Env_Name, JLI_GetPid());
714
715 printf("TRACER_MARKER: NativeMemoryTracking: env var is %s\n",envName);
716 printf("TRACER_MARKER: NativeMemoryTracking: putenv arg %s\n",pbuf);
717 envBuf = getenv(envName);
718 printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf);
719 free(envName);
720 }
721
722 }
723
724 }
725
726 }
727 }
728
729 /* copied from HotSpot function "atomll()" */
730 static int
731 parse_size(const char *s, jlong *result) {
732 jlong n = 0;
733 int args_read = sscanf(s, jlong_format_specifier(), &n);
734 if (args_read != 1) {
735 return 0;
736 }
737 while (*s != '\0' && *s >= '0' && *s <= '9') {
738 s++;
739 }
740 // 4705540: illegal if more characters are found after the first non-digit
741 if (JLI_StrLen(s) > 1) {
742 return 0;
743 }
744 switch (*s) {
745 case 'T': case 't':
746 *result = n * GB * KB;
747 return 1;
748 case 'G': case 'g':
749 *result = n * GB;
750 return 1;
751 case 'M': case 'm':
752 *result = n * MB;
753 return 1;
781 JavaVMOption *tmp;
782 maxOptions *= 2;
783 tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
784 memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
785 JLI_MemFree(options);
786 options = tmp;
787 }
788 }
789 options[numOptions].optionString = str;
790 options[numOptions++].extraInfo = info;
791
792 if (JLI_StrCCmp(str, "-Xss") == 0) {
793 jlong tmp;
794 if (parse_size(str + 4, &tmp)) {
795 threadStackSize = tmp;
796 /*
797 * Make sure the thread stack size is big enough that we won't get a stack
798 * overflow before the JVM startup code can check to make sure the stack
799 * is big enough.
800 */
801 if (threadStackSize < STACK_SIZE_MINIMUM) {
802 threadStackSize = STACK_SIZE_MINIMUM;
803 }
804 }
805 }
806
807 if (JLI_StrCCmp(str, "-Xmx") == 0) {
808 jlong tmp;
809 if (parse_size(str + 4, &tmp)) {
810 maxHeapSize = tmp;
811 }
812 }
813
814 if (JLI_StrCCmp(str, "-Xms") == 0) {
815 jlong tmp;
816 if (parse_size(str + 4, &tmp)) {
817 initialHeapSize = tmp;
818 }
819 }
820 }
821
|
713 JLI_Snprintf(envName, pbuflen, "%s%d", NMT_Env_Name, JLI_GetPid());
714
715 printf("TRACER_MARKER: NativeMemoryTracking: env var is %s\n",envName);
716 printf("TRACER_MARKER: NativeMemoryTracking: putenv arg %s\n",pbuf);
717 envBuf = getenv(envName);
718 printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf);
719 free(envName);
720 }
721
722 }
723
724 }
725
726 }
727 }
728
729 /* copied from HotSpot function "atomll()" */
730 static int
731 parse_size(const char *s, jlong *result) {
732 jlong n = 0;
733 int args_read = sscanf(s, JLONG_FORMAT_SPECIFIER, &n);
734 if (args_read != 1) {
735 return 0;
736 }
737 while (*s != '\0' && *s >= '0' && *s <= '9') {
738 s++;
739 }
740 // 4705540: illegal if more characters are found after the first non-digit
741 if (JLI_StrLen(s) > 1) {
742 return 0;
743 }
744 switch (*s) {
745 case 'T': case 't':
746 *result = n * GB * KB;
747 return 1;
748 case 'G': case 'g':
749 *result = n * GB;
750 return 1;
751 case 'M': case 'm':
752 *result = n * MB;
753 return 1;
781 JavaVMOption *tmp;
782 maxOptions *= 2;
783 tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
784 memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
785 JLI_MemFree(options);
786 options = tmp;
787 }
788 }
789 options[numOptions].optionString = str;
790 options[numOptions++].extraInfo = info;
791
792 if (JLI_StrCCmp(str, "-Xss") == 0) {
793 jlong tmp;
794 if (parse_size(str + 4, &tmp)) {
795 threadStackSize = tmp;
796 /*
797 * Make sure the thread stack size is big enough that we won't get a stack
798 * overflow before the JVM startup code can check to make sure the stack
799 * is big enough.
800 */
801 if (threadStackSize < (jlong)STACK_SIZE_MINIMUM) {
802 threadStackSize = STACK_SIZE_MINIMUM;
803 }
804 }
805 }
806
807 if (JLI_StrCCmp(str, "-Xmx") == 0) {
808 jlong tmp;
809 if (parse_size(str + 4, &tmp)) {
810 maxHeapSize = tmp;
811 }
812 }
813
814 if (JLI_StrCCmp(str, "-Xms") == 0) {
815 jlong tmp;
816 if (parse_size(str + 4, &tmp)) {
817 initialHeapSize = tmp;
818 }
819 }
820 }
821
|