Mercurial > hg > graal-jvmci-8
comparison src/share/vm/compiler/compileLog.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 | cc32ccaaf47f |
children | de6a9e811145 |
comparison
equal
deleted
inserted
replaced
10393:603ca7e51354 | 10394:813f26e34135 |
---|---|
32 | 32 |
33 CompileLog* CompileLog::_first = NULL; | 33 CompileLog* CompileLog::_first = NULL; |
34 | 34 |
35 // ------------------------------------------------------------------ | 35 // ------------------------------------------------------------------ |
36 // CompileLog::CompileLog | 36 // CompileLog::CompileLog |
37 CompileLog::CompileLog(const char* file, FILE* fp, intx thread_id) | 37 CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id) |
38 : _context(_context_buffer, sizeof(_context_buffer)) | 38 : _context(_context_buffer, sizeof(_context_buffer)) |
39 { | 39 { |
40 initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp)); | 40 initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp, true)); |
41 _file = file; | |
42 _file_end = 0; | 41 _file_end = 0; |
43 _thread_id = thread_id; | 42 _thread_id = thread_id; |
44 | 43 |
45 _identities_limit = 0; | 44 _identities_limit = 0; |
46 _identities_capacity = 400; | 45 _identities_capacity = 400; |
47 _identities = NEW_C_HEAP_ARRAY(char, _identities_capacity, mtCompiler); | 46 _identities = NEW_C_HEAP_ARRAY(char, _identities_capacity, mtCompiler); |
47 _file = NEW_C_HEAP_ARRAY(char, strlen(file_name)+1, mtCompiler); | |
48 strcpy((char*)_file, file_name); | |
48 | 49 |
49 // link into the global list | 50 // link into the global list |
50 { MutexLocker locker(CompileTaskAlloc_lock); | 51 { MutexLocker locker(CompileTaskAlloc_lock); |
51 _next = _first; | 52 _next = _first; |
52 _first = this; | 53 _first = this; |
55 | 56 |
56 CompileLog::~CompileLog() { | 57 CompileLog::~CompileLog() { |
57 delete _out; | 58 delete _out; |
58 _out = NULL; | 59 _out = NULL; |
59 FREE_C_HEAP_ARRAY(char, _identities, mtCompiler); | 60 FREE_C_HEAP_ARRAY(char, _identities, mtCompiler); |
61 FREE_C_HEAP_ARRAY(char, _file, mtCompiler); | |
60 } | 62 } |
61 | 63 |
62 | 64 |
63 // see_tag, pop_tag: Override the default do-nothing methods on xmlStream. | 65 // see_tag, pop_tag: Override the default do-nothing methods on xmlStream. |
64 // These methods provide a hook for managing the the extra context markup. | 66 // These methods provide a hook for managing the the extra context markup. |
186 void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) { | 188 void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen) { |
187 static bool called_exit = false; | 189 static bool called_exit = false; |
188 if (called_exit) return; | 190 if (called_exit) return; |
189 called_exit = true; | 191 called_exit = true; |
190 | 192 |
191 for (CompileLog* log = _first; log != NULL; log = log->_next) { | 193 CompileLog* log = _first; |
194 while (log != NULL) { | |
192 log->flush(); | 195 log->flush(); |
193 const char* partial_file = log->file(); | 196 const char* partial_file = log->file(); |
194 int partial_fd = open(partial_file, O_RDONLY); | 197 int partial_fd = open(partial_file, O_RDONLY); |
195 if (partial_fd != -1) { | 198 if (partial_fd != -1) { |
196 // print/print_cr may need to allocate large stack buffer to format | 199 // print/print_cr may need to allocate large stack buffer to format |
265 } | 268 } |
266 file->print_raw_cr("</compilation_log>"); | 269 file->print_raw_cr("</compilation_log>"); |
267 close(partial_fd); | 270 close(partial_fd); |
268 unlink(partial_file); | 271 unlink(partial_file); |
269 } | 272 } |
270 } | 273 CompileLog* next_log = log->_next; |
274 delete log; | |
275 log = next_log; | |
276 } | |
277 _first = NULL; | |
271 } | 278 } |
272 | 279 |
273 // ------------------------------------------------------------------ | 280 // ------------------------------------------------------------------ |
274 // CompileLog::finish_log | 281 // CompileLog::finish_log |
275 // | 282 // |