17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26
27 #include "logging/log.hpp"
28 #include "logging/logStream.hpp"
29 #include "memory/metaspace/metachunk.hpp"
30 #include "memory/metaspace.hpp"
31 #include "memory/metaspace/chunkManager.hpp"
32 #include "memory/metaspace/metaDebug.hpp"
33 #include "memory/metaspace/metaspaceCommon.hpp"
34 #include "memory/metaspace/occupancyMap.hpp"
35 #include "memory/metaspace/virtualSpaceNode.hpp"
36 #include "memory/virtualspace.hpp"
37 #include "runtime/os.hpp"
38 #include "services/memTracker.hpp"
39 #include "utilities/copy.hpp"
40 #include "utilities/debug.hpp"
41 #include "utilities/globalDefinitions.hpp"
42
43 namespace metaspace {
44
45 // Decide if large pages should be committed when the memory is reserved.
46 static bool should_commit_large_pages_when_reserving(size_t bytes) {
47 if (UseLargePages && UseLargePagesInMetaspace && !os::can_commit_large_page_memory()) {
48 size_t words = bytes / BytesPerWord;
49 bool is_class = false; // We never reserve large pages for the class space.
50 if (MetaspaceGC::can_expand(words, is_class) &&
51 MetaspaceGC::allowed_expansion() >= words) {
52 return true;
53 }
54 }
55
56 return false;
568 size_t chunk_size = chunk_manager->size_by_index(index);
569
570 while (free_words_in_vs() >= chunk_size) {
571 Metachunk* chunk = get_chunk_vs(chunk_size);
572 // Chunk will be allocated aligned, so allocation may require
573 // additional padding chunks. That may cause above allocation to
574 // fail. Just ignore the failed allocation and continue with the
575 // next smaller chunk size. As the VirtualSpaceNode comitted
576 // size should be a multiple of the smallest chunk size, we
577 // should always be able to fill the VirtualSpace completely.
578 if (chunk == NULL) {
579 break;
580 }
581 chunk_manager->return_single_chunk(chunk);
582 }
583 }
584 assert(free_words_in_vs() == 0, "should be empty now");
585 }
586
587 } // namespace metaspace
588
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26
27 #include "logging/log.hpp"
28 #include "logging/logStream.hpp"
29 #include "memory/metaspace/metachunk.hpp"
30 #include "memory/metaspace.hpp"
31 #include "memory/metaspace/chunkManager.hpp"
32 #include "memory/metaspace/metaDebug.hpp"
33 #include "memory/metaspace/metaspaceCommon.hpp"
34 #include "memory/metaspace/occupancyMap.hpp"
35 #include "memory/metaspace/virtualSpaceNode.hpp"
36 #include "memory/virtualspace.hpp"
37 #include "runtime/atomic.hpp"
38 #include "runtime/os.hpp"
39 #include "services/memTracker.hpp"
40 #include "utilities/copy.hpp"
41 #include "utilities/debug.hpp"
42 #include "utilities/globalDefinitions.hpp"
43
44 namespace metaspace {
45
46 // Decide if large pages should be committed when the memory is reserved.
47 static bool should_commit_large_pages_when_reserving(size_t bytes) {
48 if (UseLargePages && UseLargePagesInMetaspace && !os::can_commit_large_page_memory()) {
49 size_t words = bytes / BytesPerWord;
50 bool is_class = false; // We never reserve large pages for the class space.
51 if (MetaspaceGC::can_expand(words, is_class) &&
52 MetaspaceGC::allowed_expansion() >= words) {
53 return true;
54 }
55 }
56
57 return false;
569 size_t chunk_size = chunk_manager->size_by_index(index);
570
571 while (free_words_in_vs() >= chunk_size) {
572 Metachunk* chunk = get_chunk_vs(chunk_size);
573 // Chunk will be allocated aligned, so allocation may require
574 // additional padding chunks. That may cause above allocation to
575 // fail. Just ignore the failed allocation and continue with the
576 // next smaller chunk size. As the VirtualSpaceNode comitted
577 // size should be a multiple of the smallest chunk size, we
578 // should always be able to fill the VirtualSpace completely.
579 if (chunk == NULL) {
580 break;
581 }
582 chunk_manager->return_single_chunk(chunk);
583 }
584 }
585 assert(free_words_in_vs() == 0, "should be empty now");
586 }
587
588 } // namespace metaspace
|