mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-25 05:45:11 +02:00
8013329: File leak in hotspot/src/share/vm/compiler/compileBroker.cpp
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
This commit is contained in:
parent
6ae26f2e94
commit
d6efb99686
3 changed files with 30 additions and 28 deletions
|
@ -34,17 +34,18 @@ CompileLog* CompileLog::_first = NULL;
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// CompileLog::CompileLog
|
||||
CompileLog::CompileLog(const char* file, FILE* fp, intx thread_id)
|
||||
CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id)
|
||||
: _context(_context_buffer, sizeof(_context_buffer))
|
||||
{
|
||||
initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp));
|
||||
_file = file;
|
||||
initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp, true));
|
||||
_file_end = 0;
|
||||
_thread_id = thread_id;
|
||||
|
||||
_identities_limit = 0;
|
||||
_identities_capacity = 400;
|
||||
_identities = NEW_C_HEAP_ARRAY(char, _identities_capacity, mtCompiler);
|
||||
_file = NEW_C_HEAP_ARRAY(char, strlen(file_name)+1, mtCompiler);
|
||||
strcpy((char*)_file, file_name);
|
||||
|
||||
// link into the global list
|
||||
{ MutexLocker locker(CompileTaskAlloc_lock);
|
||||
|
@ -57,6 +58,7 @@ CompileLog::~CompileLog() {
|
|||
delete _out;
|
||||
_out = NULL;
|
||||
FREE_C_HEAP_ARRAY(char, _identities, mtCompiler);
|
||||
FREE_C_HEAP_ARRAY(char, _file, mtCompiler);
|
||||
}
|
||||
|
||||
|
||||
|
@ -188,7 +190,8 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
|
|||
if (called_exit) return;
|
||||
called_exit = true;
|
||||
|
||||
for (CompileLog* log = _first; log != NULL; log = log->_next) {
|
||||
CompileLog* log = _first;
|
||||
while (log != NULL) {
|
||||
log->flush();
|
||||
const char* partial_file = log->file();
|
||||
int partial_fd = open(partial_file, O_RDONLY);
|
||||
|
@ -267,7 +270,11 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
|
|||
close(partial_fd);
|
||||
unlink(partial_file);
|
||||
}
|
||||
CompileLog* next_log = log->_next;
|
||||
delete log;
|
||||
log = next_log;
|
||||
}
|
||||
_first = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue