Deleting buffers?

In the extension I’m writing I may need to change the size of a buffer (which assumes its contents will be discarded and started anew). How best should I delete a buffer so that a new buffer of a different size might be created for the same variable?

Create the new buffer, copy the old content, assign new buffer to old variable. The old one will be garbage collected

Ah, so it’s all taken care of nicely and it’s as easy as the following, if I don’t care about the old contents:

mybuffer: Buffer = pins.createBuffer(128) lots of stuff..
..some time later...
newbuffer: Buffer = pins.createBuffer(256)
mybuffer = newbuffer

Yep. It will be cleaned up. If you run out of memory, you might consider first clearing the old variable, then allocate the new one to allow the GC to reclaim the space.