1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2020 SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #ifndef SHARE_MEMORY_METASPACE_CONSTANTS_HPP 27 #define SHARE_MEMORY_METASPACE_CONSTANTS_HPP 28 29 #include "memory/allocation.hpp" 30 #include "memory/metaspace/chunkLevel.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 33 namespace metaspace { 34 35 class Settings : public AllStatic { 36 37 // Granularity, in bytes, metaspace is committed with. 38 static size_t _commit_granule_bytes; 39 40 // Granularity, in words, metaspace is committed with. 41 static size_t _commit_granule_words; 42 43 // The default size of a non-class VirtualSpaceNode (unless created differently). 44 // Must be a multiple of the root chunk size. 45 static const size_t _virtual_space_node_default_word_size = chunklevel::MAX_CHUNK_WORD_SIZE * 2; // lets go with 8mb virt size. Seems a good compromise betw. virt and mapping fragmentation. 46 47 // Alignment of the base address of a virtual space node 48 static const size_t _virtual_space_node_reserve_alignment_words = chunklevel::MAX_CHUNK_WORD_SIZE; 49 50 // When allocating from a chunk, if the remaining area in the chunk is too small to hold 51 // the requested size, we attempt to double the chunk size in place... 52 static const bool _enlarge_chunks_in_place = true; 53 54 // .. but we do only do this for chunks below a given size to prevent unnecessary memory blowup. 55 static const size_t _enlarge_chunks_in_place_max_word_size = 256 * K; 56 57 // Whether or not chunks handed out to an arena start out fully committed; 58 // if true, this deactivates committing-on-demand (irregardless of whether 59 // we uncommit free chunks). 60 static bool _new_chunks_are_fully_committed; 61 62 // If true, chunks equal or larger than a commit granule are uncommitted 63 // after being returned to the freelist. 64 static bool _uncommit_free_chunks; 65 66 // If true, metablock allocations are guarded and periodically checked. 67 DEBUG_ONLY(static bool _use_allocation_guard;) 68 69 // If true, we handle deallocated blocks (default). 70 DEBUG_ONLY(static bool _handle_deallocations;) 71 72 public: 73 74 static size_t commit_granule_bytes() { return _commit_granule_bytes; } 75 static size_t commit_granule_words() { return _commit_granule_words; } 76 static bool new_chunks_are_fully_committed() { return _new_chunks_are_fully_committed; } 77 static size_t virtual_space_node_default_word_size() { return _virtual_space_node_default_word_size; } 78 static size_t virtual_space_node_reserve_alignment_words() { return _virtual_space_node_reserve_alignment_words; } 79 static bool enlarge_chunks_in_place() { return _enlarge_chunks_in_place; } 80 static size_t enlarge_chunks_in_place_max_word_size() { return _enlarge_chunks_in_place_max_word_size; } 81 static bool uncommit_free_chunks() { return _uncommit_free_chunks; } 82 83 static bool use_allocation_guard() { return DEBUG_ONLY(_use_allocation_guard) NOT_DEBUG(false); } 84 static bool handle_deallocations() { return DEBUG_ONLY(_handle_deallocations) NOT_DEBUG(true); } 85 86 static void ergo_initialize(); 87 88 static void print_on(outputStream* st); 89 90 }; 91 92 } // namespace metaspace 93 94 #endif // SHARE_MEMORY_METASPACE_BLOCKFREELIST_HPP