2.10 - Close Pcap and PcapDumper handles

When you are done with a Pcap object or PcapDumper you must call its close() method. This ensures that all resources being held are properly released. Especially when working with decoded packets. They allocate fair amount of native memory, outside of JRE reporting and management. It is a very good idea to release that memory when no longer needed.

Here are some specific close methods:

  • Pcap.close()
  • PcapDumper.close()

It is especially neccessary to close the PcapDumper object, as it will hold on to the open file and lock it. You will not be able to manipulate that file until the dumper is closed out.