@@ -152,38 +152,6 @@ static uv_async_t dispatch_debug_messages_async;
152
152
static Isolate* node_isolate = nullptr ;
153
153
static v8::Platform* default_platform;
154
154
155
- class ArrayBufferAllocator : public ArrayBuffer ::Allocator {
156
- public:
157
- // Impose an upper limit to avoid out of memory errors that bring down
158
- // the process.
159
- static const size_t kMaxLength = 0x3fffffff ;
160
- static ArrayBufferAllocator the_singleton;
161
- virtual ~ArrayBufferAllocator () = default ;
162
- virtual void * Allocate (size_t length) override ;
163
- virtual void * AllocateUninitialized (size_t length) override ;
164
- virtual void Free (void * data, size_t length) override ;
165
- private:
166
- ArrayBufferAllocator () = default ;
167
- DISALLOW_COPY_AND_ASSIGN (ArrayBufferAllocator);
168
- };
169
-
170
- ArrayBufferAllocator ArrayBufferAllocator::the_singleton;
171
-
172
-
173
- void * ArrayBufferAllocator::Allocate (size_t length) {
174
- return calloc (length, 1 );
175
- }
176
-
177
-
178
- void * ArrayBufferAllocator::AllocateUninitialized (size_t length) {
179
- return malloc (length);
180
- }
181
-
182
-
183
- void ArrayBufferAllocator::Free (void * data, size_t length) {
184
- free (data);
185
- }
186
-
187
155
188
156
static void CheckImmediate (uv_check_t * handle) {
189
157
Environment* env = Environment::from_immediate_check_handle (handle);
@@ -3711,8 +3679,6 @@ void Init(int* argc,
3711
3679
V8::SetFlagsFromString (expose_debug_as, sizeof (expose_debug_as) - 1 );
3712
3680
}
3713
3681
3714
- V8::SetArrayBufferAllocator (&ArrayBufferAllocator::the_singleton);
3715
-
3716
3682
if (!use_debug_agent) {
3717
3683
RegisterDebugSignalHandler ();
3718
3684
}
@@ -3914,7 +3880,10 @@ Environment* CreateEnvironment(Isolate* isolate,
3914
3880
// node instance.
3915
3881
static void StartNodeInstance (void * arg) {
3916
3882
NodeInstanceData* instance_data = static_cast <NodeInstanceData*>(arg);
3917
- Isolate* isolate = Isolate::New ();
3883
+ Isolate::CreateParams params;
3884
+ ArrayBufferAllocator array_buffer_allocator;
3885
+ params.array_buffer_allocator = &array_buffer_allocator;
3886
+ Isolate* isolate = Isolate::New (params);
3918
3887
if (track_heap_objects) {
3919
3888
isolate->GetHeapProfiler ()->StartTrackingHeapObjects (true );
3920
3889
}
0 commit comments