File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -209,9 +209,10 @@ void SerializerContext::ReleaseBuffer(const FunctionCallbackInfo<Value>& args) {
209
209
// Note: Both ValueSerializer and this Buffer::New() variant use malloc()
210
210
// as the underlying allocator.
211
211
std::pair<uint8_t *, size_t > ret = ctx->serializer_ .Release ();
212
- auto buf = Buffer::New (ctx->env (),
212
+ auto buf = Buffer::Copy (ctx->env (),
213
213
reinterpret_cast <char *>(ret.first ),
214
214
ret.second );
215
+ free (ret.first );
215
216
216
217
if (!buf.IsEmpty ()) {
217
218
args.GetReturnValue ().Set (buf.ToLocalChecked ());
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ // Flags: --expose-gc
3
+
4
+ require ( '../common' ) ;
5
+ const v8 = require ( 'v8' ) ;
6
+ const assert = require ( 'assert' ) ;
7
+
8
+ const before = process . memoryUsage . rss ( ) ;
9
+
10
+ for ( let i = 0 ; i < 1000000 ; i ++ ) {
11
+ v8 . serialize ( '' ) ;
12
+ }
13
+
14
+ global . gc ( ) ;
15
+
16
+ const after = process . memoryUsage . rss ( ) ;
17
+
18
+ if ( process . config . variables . asan ) {
19
+ assert ( before * 10 > after , `asan: before=${ before } after=${ after } ` ) ;
20
+ } else {
21
+ assert ( after - before < 1024 * 1024 * 10 , `before=${ before } after=${ after } ` ) ;
22
+ }
You can’t perform that action at this time.
0 commit comments