geo-data / node-mapserv

All the functionality of Mapserver's `mapserv` CGI program made available to Node.js
BSD 2-Clause "Simplified" License
21 stars 8 forks source link

Zero-copy mapserv output when creating response `Buffer` #5

Closed homme closed 11 years ago

homme commented 11 years ago

In void Map::MapservAfter(uv_work_t *req) the mapserver output is currently copied from a Map::gdBuffer object to a new Node Buffer object using the following public constructor:

static Buffer* New(char *data, size_t len);

Efficiency gains can be made by having the Buffer take ownership of the existing buffer, removing the need for the copy, using the following public constructor:

static Buffer* New(char *data, size_t length,
                   free_callback callback, void *hint);

The free_callback would be a wrapper around msFree().

homme commented 11 years ago

Fixed in e87af97. A side effect is that memory allocated for mapserver output is now cleaned up during the V8 garbage collection cycle instead of at the end of each request as was previously the case.