Mercurial > hg > graal-jvmci-8
comparison src/share/vm/compiler/compileBroker.cpp @ 10394:813f26e34135
8013329: File leak in hotspot/src/share/vm/compiler/compileBroker.cpp
Summary: Added calling of the destructor of CompileLog so that files are closed. Added/moved memory allocation/deallocation of the string that contains the name of the log file to class CompileLog.
Reviewed-by: kvn, roland
author | anoll |
---|---|
date | Mon, 03 Jun 2013 08:52:20 +0200 |
parents | 6f3fd5150b67 |
children | f2110083203d |
comparison
equal
deleted
inserted
replaced
10393:603ca7e51354 | 10394:813f26e34135 |
---|---|
1640 // CompileBroker::init_compiler_thread_log | 1640 // CompileBroker::init_compiler_thread_log |
1641 // | 1641 // |
1642 // Set up state required by +LogCompilation. | 1642 // Set up state required by +LogCompilation. |
1643 void CompileBroker::init_compiler_thread_log() { | 1643 void CompileBroker::init_compiler_thread_log() { |
1644 CompilerThread* thread = CompilerThread::current(); | 1644 CompilerThread* thread = CompilerThread::current(); |
1645 char fileBuf[4*K]; | 1645 char file_name[4*K]; |
1646 FILE* fp = NULL; | 1646 FILE* fp = NULL; |
1647 char* file = NULL; | |
1648 intx thread_id = os::current_thread_id(); | 1647 intx thread_id = os::current_thread_id(); |
1649 for (int try_temp_dir = 1; try_temp_dir >= 0; try_temp_dir--) { | 1648 for (int try_temp_dir = 1; try_temp_dir >= 0; try_temp_dir--) { |
1650 const char* dir = (try_temp_dir ? os::get_temp_directory() : NULL); | 1649 const char* dir = (try_temp_dir ? os::get_temp_directory() : NULL); |
1651 if (dir == NULL) { | 1650 if (dir == NULL) { |
1652 jio_snprintf(fileBuf, sizeof(fileBuf), "hs_c" UINTX_FORMAT "_pid%u.log", | 1651 jio_snprintf(file_name, sizeof(file_name), "hs_c" UINTX_FORMAT "_pid%u.log", |
1653 thread_id, os::current_process_id()); | 1652 thread_id, os::current_process_id()); |
1654 } else { | 1653 } else { |
1655 jio_snprintf(fileBuf, sizeof(fileBuf), | 1654 jio_snprintf(file_name, sizeof(file_name), |
1656 "%s%shs_c" UINTX_FORMAT "_pid%u.log", dir, | 1655 "%s%shs_c" UINTX_FORMAT "_pid%u.log", dir, |
1657 os::file_separator(), thread_id, os::current_process_id()); | 1656 os::file_separator(), thread_id, os::current_process_id()); |
1658 } | 1657 } |
1659 fp = fopen(fileBuf, "at"); | 1658 |
1659 fp = fopen(file_name, "at"); | |
1660 if (fp != NULL) { | 1660 if (fp != NULL) { |
1661 file = NEW_C_HEAP_ARRAY(char, strlen(fileBuf)+1, mtCompiler); | 1661 if (LogCompilation && Verbose) { |
1662 strcpy(file, fileBuf); | 1662 tty->print_cr("Opening compilation log %s", file_name); |
1663 break; | 1663 } |
1664 CompileLog* log = new(ResourceObj::C_HEAP, mtCompiler) CompileLog(file_name, fp, thread_id); | |
1665 thread->init_log(log); | |
1666 | |
1667 if (xtty != NULL) { | |
1668 ttyLocker ttyl; | |
1669 // Record any per thread log files | |
1670 xtty->elem("thread_logfile thread='%d' filename='%s'", thread_id, file_name); | |
1671 } | |
1672 return; | |
1664 } | 1673 } |
1665 } | 1674 } |
1666 if (fp == NULL) { | 1675 warning("Cannot open log file: %s", file_name); |
1667 warning("Cannot open log file: %s", fileBuf); | |
1668 } else { | |
1669 if (LogCompilation && Verbose) | |
1670 tty->print_cr("Opening compilation log %s", file); | |
1671 CompileLog* log = new(ResourceObj::C_HEAP, mtCompiler) CompileLog(file, fp, thread_id); | |
1672 thread->init_log(log); | |
1673 | |
1674 if (xtty != NULL) { | |
1675 ttyLocker ttyl; | |
1676 | |
1677 // Record any per thread log files | |
1678 xtty->elem("thread_logfile thread='%d' filename='%s'", thread_id, file); | |
1679 } | |
1680 } | |
1681 } | 1676 } |
1682 | 1677 |
1683 // ------------------------------------------------------------------ | 1678 // ------------------------------------------------------------------ |
1684 // CompileBroker::set_should_block | 1679 // CompileBroker::set_should_block |
1685 // | 1680 // |