MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / testJava

Function testJava

src/dmtcp_launch.cpp:625–664  ·  view source on GitHub ↗

FIXME: Remove this when DMTCP supports zero-mapped pages

Source from the content-addressed store, hash-verified

623
624// FIXME: Remove this when DMTCP supports zero-mapped pages
625static int
626testJava(const char **argv)
627{
628 static const char *theJavaWarning =
629 "\n**** WARNING: Sun/Oracle Java claims a large amount of memory\n"
630 "**** for its heap on startup. As of DMTCP version 1.2.4, DMTCP _does_\n"
631 "**** handle zero-mapped virtual memory, but it may take up to a\n"
632 "**** minute. This will be fixed to be much faster in a future\n"
633 "**** version of DMTCP. In the meantime, if your Java supports it,\n"
634 "**** use the -Xmx flag for a smaller heap: e.g. java -Xmx64M javaApp\n"
635 "**** (Invoke dmtcp_launch with --quiet to avoid this msg.)\n\n";
636
637 if (getenv(ENV_VAR_QUIET) != NULL
638 && strcmp(getenv(ENV_VAR_QUIET), "0") != 0) {
639 return 0;
640 }
641 if (strcmp(argv[0], "java") == 0) {
642 while (*(++argv) != NULL) {
643 if (strncmp(*argv, "-Xmx", sizeof("-Xmx") - 1) == 0) {
644 return 0; // The user called java with -Xmx. No need for warning.
645 }
646 }
647 }
648
649 // If user has more than 4 GB of RAM, warn them that -Xmx is faster.
650 int fd;
651 char buf[100];
652 static const char *meminfoPrefix = "MemTotal: ";
653 if ((fd = open("/proc/meminfo", O_RDONLY)) != -1 &&
654 read(fd, buf, sizeof(meminfoPrefix) + 16) == sizeof(meminfoPrefix) + 16 &&
655 strncmp(buf, meminfoPrefix, sizeof(meminfoPrefix) + 1) == 0 &&
656 atol(buf + sizeof(meminfoPrefix)) > 17000000) { /* units of kB : mem > 4
657 GB */
658 JASSERT_STDERR << theJavaWarning;
659 }
660 if (fd != -1) {
661 close(fd);
662 }
663 return -1;
664}
665
666static bool
667testSetuid(const char *filename)

Callers 1

mainFunction · 0.85

Calls 2

openFunction · 0.70
closeFunction · 0.70

Tested by

no test coverage detected