I am working on an application that needs to transfer high amount of data via udp. I have written an erl_driver to pull data off an interface as fast as I can. I am using driver_alloc_binary() for allocating binaries for reading data into. After I transfer the binary to the port owner, I call driver_free_binary().
Here is an example of how I am reading the data.
while (true) {
auto pBinary = driver_alloc_binary();
if (pBinary == nullptr) {
printf("ERROR: Ran out of memory\r\n");
continue;
}
auto readCount = read(pBinary, ...);
driver_free_binary(pBinary);
}
I am also sending out data. I implemented the outputv callback, and call writev function to write the IO vector to the interface.
After running for short period of time, The VM dies on me with the message “Killed”. By looking at the logs, I can see that it died because of an out of memory (OOM) exception. I know this is really vague, but does anyone have some pointers on how I can debug this. I’m not sure how to use the various tools that are exists, nor do I know which tools would be best for this. For what it’s worth, the system runs on a server that is memory constraint to 2GB of memory.