1. A computer-implemented method, comprising: using a virtual machine to perform: determining whether a set of program code comprises one or more references to a data object after an operation to generate a copy of the data object, wherein the set of program code is executable using the virtual machine; if the set of program code does not comprise one or more references to the data object after the operation to generate the copy of the data object, generating a set of optimized program code, comprising replacing the operation to generate the copy of the data object in the set of program code with an operation to update a reference in the set of optimized program code; determining whether the set of program code comprises an operation to generate a copy of a buffer object; and if the set of program code comprises the operation to generate the copy of the buffer object, generating a set of further optimized program code, wherein the set of further optimized program code comprises an allocation of one or more memory pages to store the buffer object with a copy-on-write parameter instead of the operation to generate the copy of the buffer object.