Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2072)

Unified Diff: runtime/vm/snapshot.h

Issue 2650693004: VM: Fix memory leaks during isolate spawning (Closed)
Patch Set: Rebased & Renamed TakeBuffer -> StealBuffer Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.h
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index 97918208a30157abb0596215b96384a499a10c86..400a479960d080a5b03945bf0f30e2f1fa2708c0 100644
--- a/runtime/vm/snapshot.h
+++ b/runtime/vm/snapshot.h
@@ -660,7 +660,10 @@ class BaseWriter : public StackResource {
data[Snapshot::kSnapshotFlagIndex] = kind;
}
- void FreeBuffer() { dealloc_(stream_.buffer()); }
+ void FreeBuffer() {
+ dealloc_(stream_.buffer());
+ stream_.set_buffer(NULL);
+ }
private:
WriteStream stream_;
@@ -976,19 +979,47 @@ class ScriptSnapshotWriter : public SnapshotWriter {
};
+class SerializedObjectBuffer : public StackResource {
+ public:
+ SerializedObjectBuffer()
+ : StackResource(Thread::Current()),
+ object_data_(NULL),
+ object_length_(0) {}
+
+ virtual ~SerializedObjectBuffer() { free(object_data_); }
+
+ void StealBuffer(uint8_t** out_data, intptr_t* out_length) {
+ *out_data = object_data_;
+ *out_length = object_length_;
+
+ object_data_ = NULL;
+ object_length_ = 0;
+ }
+
+ uint8_t** data_buffer() { return &object_data_; }
+ intptr_t* data_length() { return &object_length_; }
+
+ private:
+ uint8_t* object_data_;
+ intptr_t object_length_;
+};
+
+
class MessageWriter : public SnapshotWriter {
public:
static const intptr_t kInitialSize = 512;
MessageWriter(uint8_t** buffer,
ReAlloc alloc,
DeAlloc dealloc,
- bool can_send_any_object);
+ bool can_send_any_object,
+ intptr_t* buffer_len = NULL);
~MessageWriter() {}
void WriteMessage(const Object& obj);
private:
ForwardList forward_list_;
+ intptr_t* buffer_len_;
DISALLOW_COPY_AND_ASSIGN(MessageWriter);
};
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698