(vm_create): Likewise.
* src/mm/memory.c (memory_thread): Rewritten to use new variables.
* src/vmcore/options.c (errno.h): Added.
(stdint.h): Likewise
(stdio.h): Likewise.
(stdlib.h): Likewise.
(opt_verbosememory): Removed.
(opt_ProfileGCMemoryUsage): Added.
(opt_ProfileMemoryUsage): Likewise.
(opt_ProfileMemoryUsageGNUPlot): Likewise.
(options_XX): Likewise.
(options_xx): Implemented.
* src/vmcore/options.h (stdint.h): Added.
(option_t): Likewise.
(opt_ProfileGCMemoryUsage): Likewise.
(opt_ProfileMemoryUsage): Likewise.
(opt_ProfileMemoryUsageGNUPlot): Likewise.
(options_xx): Changed signature.
* src/vmcore/statistics.c (statistics_print_gc_memory_usage):
Rewritten to use new variables and GNU Plot output.
* configure.ac (AC_CHECK_FUNCS): Added atoi, atol, strchr, strncmp.
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
dnl 02110-1301, USA.
dnl
-dnl $Id: configure.ac 8056 2007-06-10 14:49:57Z michi $
+dnl $Id: configure.ac 8112 2007-06-20 17:54:36Z twisti $
dnl Process this file with autoconf to produce a configure script.
AC_FUNC_MMAP
dnl keep them alpha-sorted!
+AC_CHECK_FUNCS([atoi])
+AC_CHECK_FUNCS([atol])
AC_CHECK_FUNCS([calloc])
AC_CHECK_FUNCS([confstr])
AC_CHECK_FUNCS([free])
AC_CHECK_FUNCS([open])
AC_CHECK_FUNCS([scandir])
AC_CHECK_FUNCS([select])
+AC_CHECK_FUNCS([strchr])
AC_CHECK_FUNCS([strdup])
AC_CHECK_FUNCS([strerror])
+AC_CHECK_FUNCS([strncmp])
AC_CHECK_FUNCS([strstr])
AC_CHECK_FUNCS([time])
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: memory.c 7902 2007-05-11 22:33:15Z twisti $
+ $Id: memory.c 8112 2007-06-20 17:54:36Z twisti $
*/
#if defined(ENABLE_THREADS) && !defined(NDEBUG)
static void memory_thread(void)
{
+ int32_t seconds;
+
+ /* If both arguments are specified, use the value of
+ ProfileMemoryUsage. */
+
+ if (opt_ProfileGCMemoryUsage)
+ seconds = opt_ProfileGCMemoryUsage;
+
+ if (opt_ProfileMemoryUsage)
+ seconds = opt_ProfileMemoryUsage;
+
while (true) {
- /* sleep thread for 2 seconds */
+ /* sleep thread */
- threads_sleep(2 * 1000, 0);
+ threads_sleep(seconds * 1000, 0);
# if defined(ENABLE_STATISTICS)
- /* print current date and time */
+ /* Print current date and time (only when we print to the
+ stdout). */
- statistics_print_date();
+ if (!opt_ProfileMemoryUsageGNUPlot)
+ statistics_print_date();
/* print memory usage */
- statistics_print_memory_usage();
+ if (opt_ProfileMemoryUsage)
+ statistics_print_memory_usage();
/* print GC memory usage */
- statistics_print_gc_memory_usage();
+ if (opt_ProfileGCMemoryUsage)
+ statistics_print_gc_memory_usage();
# endif
}
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: vm.c 8108 2007-06-20 12:05:26Z ajordan $
+ $Id: vm.c 8112 2007-06-20 17:54:36Z twisti $
*/
{
puts(" -v write state-information");
#if !defined(NDEBUG)
- puts(" -verbose[:call|exception|jit|memory|threads]");
+ puts(" -verbose[:call|exception|jit|threads]");
puts(" enable specific verbose output");
puts(" -debug-color colored output for ANSI terms");
#endif
initverbose = true;
compileverbose = true;
}
- else if (strcmp("memory", opt_arg) == 0) {
- opt_verbosememory = true;
-
-# if defined(ENABLE_STATISTICS)
- /* we also need statistics */
-
- opt_stat = true;
-# endif
- }
else if (strcmp("threads", opt_arg) == 0) {
opt_verbosethreads = true;
}
# if !defined(NDEBUG)
/* start the memory profiling thread */
- if (opt_verbosememory)
+ if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage)
if (!memory_start_thread())
vm_abort("vm_create: memory_start_thread failed");
# endif
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: options.c 8062 2007-06-11 08:12:14Z twisti $
+ $Id: options.c 8112 2007-06-20 17:54:36Z twisti $
*/
#include "config.h"
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#if defined(HAVE_STRING_H)
# include <string.h>
#endif
#include <limits.h>
-#include "vm/types.h"
-
#include "mm/memory.h"
+
#include "native/jni.h"
+
+#include "vm/vm.h"
+
#include "vmcore/options.h"
bool opt_verbosejni = false;
bool opt_verbosecall = false; /* trace all method invocation */
bool opt_verboseexception = false;
-bool opt_verbosememory = false;
bool opt_verbosethreads = false;
bool showmethods = false;
const char *opt_filter_show_method = 0;
#endif
+
+/* -XX options ****************************************************************/
+
+/* NOTE: For better readability keep these alpha-sorted. */
+
+int32_t opt_ProfileGCMemoryUsage = 0;
+int32_t opt_ProfileMemoryUsage = 0;
+FILE *opt_ProfileMemoryUsageGNUPlot = NULL;
+
+
+enum {
+ OPT_ProfileGCMemoryUsage,
+ OPT_ProfileMemoryUsage,
+ OPT_ProfileMemoryUsageGNUPlot
+};
+
+
+option_t options_XX[] = {
+ { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, "" },
+ { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, "" },
+ { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, "" },
+};
+
+
/* options_get *****************************************************************
DOCUMENT ME!!!
*******************************************************************************/
-void options_xx(char *opt_arg)
+void options_xx(const char *name)
{
- log_println("opt_arg: %s", opt_arg);
+ char *end;
+ int32_t length;
+ char *value;
+ int32_t option;
+ char *filename;
+ FILE *file;
+ int32_t i;
+
+ log_println("name: %s", name);
+
+ /* Search for a ':' in the option name and get the option name
+ length and the value of the option. */
+
+ end = strchr(name, ':');
+
+ if (end == NULL) {
+ length = strlen(name);
+ value = NULL;
+ }
+ else {
+ length = end - name;
+ value = end + 1;
+ }
+
+ /* search the option in the option array */
+
+ option = OPT_ERROR;
+
+ for (i = 0; options_XX[i].name != NULL; i++) {
+ if (strncmp(options_XX[i].name, name, length) == 0) {
+ option = options_XX[i].option;
+ break;
+ }
+ }
+
+ /* process the option */
+
+ switch (option) {
+ case OPT_ProfileGCMemoryUsage:
+ if (value == NULL)
+ opt_ProfileGCMemoryUsage = 5;
+ else
+ opt_ProfileGCMemoryUsage = atoi(value);
+ break;
+
+ case OPT_ProfileMemoryUsage:
+ if (value == NULL)
+ opt_ProfileMemoryUsage = 5;
+ else
+ opt_ProfileMemoryUsage = atoi(value);
+
+# if defined(ENABLE_STATISTICS)
+ /* we also need statistics */
+
+ opt_stat = true;
+# endif
+ break;
+
+ case OPT_ProfileMemoryUsageGNUPlot:
+ if (value == NULL)
+ filename = "profile.dat";
+ else
+ filename = value;
+
+ file = fopen(filename, "w");
+
+ if (file == NULL)
+ vm_abort("options_xx: fopen failed: %s", strerror(errno));
+
+ opt_ProfileMemoryUsageGNUPlot = file;
+ break;
+
+ default:
+ printf("Unknown option: -XX:%s\n", name);
+ break;
+ }
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: options.h 8062 2007-06-11 08:12:14Z twisti $
+ $Id: options.h 8112 2007-06-20 17:54:36Z twisti $
*/
#include "config.h"
+
+#include <stdint.h>
+
#include "vm/types.h"
#include "native/jni.h"
};
+typedef struct option_t option_t;
+
+struct option_t {
+ char *name;
+ int32_t option;
+ char *doc;
+};
+
+
/* global variables ***********************************************************/
extern s4 opt_index;
extern bool opt_verbosejni;
extern bool opt_verbosecall;
extern bool opt_verboseexception;
-extern bool opt_verbosememory;
extern bool opt_verbosethreads;
extern bool showmethods;
extern const char *opt_filter_show_method;
#endif
+
+/* -XX options ****************************************************************/
+
+/* NOTE: For better readability keep these alpha-sorted. */
+
+extern int32_t opt_ProfileGCMemoryUsage;
+extern int32_t opt_ProfileMemoryUsage;
+extern FILE *opt_ProfileMemoryUsageGNUPlot;
+
+
/* function prototypes ********************************************************/
s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args);
-void options_xx(char *opt_arg);
+void options_xx(const char *name);
#endif /* _OPTIONS_H */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: statistics.c 8094 2007-06-16 01:15:41Z ajordan $
+ $Id: statistics.c 8112 2007-06-20 17:54:36Z twisti $
*/
void statistics_print_gc_memory_usage(void)
{
- log_println("GC memory usage -------------------");
- log_println("");
- log_println("max. heap size: %10lld", gc_get_max_heap_size());
- log_println("");
- log_println("heap size: %10lld", gc_get_heap_size());
- log_println("free: %10lld", gc_get_free_bytes());
- log_println("used: %10lld", gc_get_total_bytes());
- log_println("");
+ static int64_t count = 0;
+ int64_t max;
+ int64_t size;
+ int64_t free;
+ int64_t used;
+ int64_t total;
+
+ count++;
+
+ max = gc_get_max_heap_size();
+ size = gc_get_heap_size();
+ free = gc_get_free_bytes();
+ used = size - free;
+ total = gc_get_total_bytes();
+
+ if (opt_ProfileMemoryUsageGNUPlot) {
+ if (count == 1)
+ fprintf(opt_ProfileMemoryUsageGNUPlot, "plot \"profile.dat\" using 1:2 with lines title \"max. Java heap size\", \"profile.dat\" using 1:3 with lines title \"Java heap size\", \"profile.dat\" using 1:4 with lines title \"used\", \"profile.dat\" using 1:5 with lines title \"free\"\n");
+
+ fprintf(opt_ProfileMemoryUsageGNUPlot, "%lld %lld% lld %lld %lld\n", count, max, size, used, free);
+ }
+ else {
+ log_println("GC memory usage -------------------");
+ log_println("");
+ log_println("max. Java heap size: %10lld", max);
+ log_println("");
+ log_println("Java heap size: %10lld", size);
+ log_println("used: %10lld", used);
+ log_println("free: %10lld", free);
+ log_println("totally used: %10lld", total);
+ log_println("");
+ }
}