summaryrefslogtreecommitdiff
path: root/compiler/image_writer.h
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/image_writer.h')
-rw-r--r--compiler/image_writer.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/image_writer.h b/compiler/image_writer.h
index 8c84b686fa..4418879e73 100644
--- a/compiler/image_writer.h
+++ b/compiler/image_writer.h
@@ -18,6 +18,7 @@
#define ART_COMPILER_IMAGE_WRITER_H_
#include <stdint.h>
+#include <valgrind.h>
#include <cstddef>
#include <memory>
@@ -56,7 +57,15 @@ class ImageWriter FINAL {
CHECK_NE(image_begin, 0U);
}
- ~ImageWriter() {}
+ ~ImageWriter() {
+ // For interned strings a large array is allocated to hold all the character data and avoid
+ // overhead. However, no GC is run anymore at this point. As the array is likely large, it
+ // will be allocated in the large object space, where valgrind can track every single
+ // allocation. Not explicitly freeing that array will be recognized as a leak.
+ if (RUNNING_ON_VALGRIND != 0) {
+ FreeStringDataArray();
+ }
+ }
bool PrepareImageAddressSpace();
@@ -254,6 +263,9 @@ class ImageWriter FINAL {
// Calculate the sum total of the bin slot sizes in [0, up_to). Defaults to all bins.
size_t GetBinSizeSum(Bin up_to = kBinSize) const;
+ // Release the string_data_array_.
+ void FreeStringDataArray();
+
const CompilerDriver& compiler_driver_;
// Beginning target image address for the output image.
@@ -306,6 +318,8 @@ class ImageWriter FINAL {
size_t bin_slot_sizes_[kBinSize]; // Number of bytes in a bin
size_t bin_slot_count_[kBinSize]; // Number of objects in a bin
+ void* string_data_array_; // The backing for the interned strings.
+
friend class FixupVisitor;
friend class FixupClassVisitor;
DISALLOW_COPY_AND_ASSIGN(ImageWriter);