8201265: Native memory leak in ClassLoader::add_to_exploded_build_list
authorhseigel
Wed, 11 Apr 2018 10:05:02 -0400
changeset 49747 376792a6e9da
parent 49746 b17256b5c047
child 49748 6a880e576856
8201265: Native memory leak in ClassLoader::add_to_exploded_build_list Summary: Allocate from temporary thread local memory instead of C heap memory. Reviewed-by: coleenp, dholmes, lfoltan
src/hotspot/share/classfile/classLoader.cpp
--- a/src/hotspot/share/classfile/classLoader.cpp	Wed Apr 11 13:52:23 2018 +0200
+++ b/src/hotspot/share/classfile/classLoader.cpp	Wed Apr 11 10:05:02 2018 -0400
@@ -797,7 +797,6 @@
       struct stat st;
       if (os::stat(path, &st) == 0) {
         // File or directory found
-        Thread* THREAD = Thread::current();
         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
         // If the path specification is valid, enter it into this module's list
         if (new_entry != NULL) {
@@ -867,7 +866,6 @@
       struct stat st;
       if (os::stat(path, &st) == 0) {
         // Directory found
-        Thread* THREAD = Thread::current();
         ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, CHECK);
 
         // Check for a jimage
@@ -912,7 +910,7 @@
   const char file_sep = os::file_separator()[0];
   // 10 represents the length of "modules" + 2 file separators + \0
   size_t len = strlen(home) + strlen(module_name) + 10;
-  char *path = NEW_C_HEAP_ARRAY(char, len, mtModule);
+  char *path = NEW_RESOURCE_ARRAY(char, len);
   jio_snprintf(path, len, "%s%cmodules%c%s", home, file_sep, file_sep, module_name);
 
   struct stat st;
@@ -934,7 +932,6 @@
       log_info(class, load)("path: %s", path);
     }
   }
-  FREE_C_HEAP_ARRAY(char, path);
 }
 
 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st,