Permalink
Browse files

Clarified use of zmq_msg_close

  • Loading branch information...
1 parent b1e054c commit b67473b6df3d57b9e3917b0e55ba83691ada346d @hintjens hintjens committed Dec 23, 2012
Showing with 4 additions and 3 deletions.
  1. +0 −1 bin/INSTALL
  2. +3 −1 chapter1.txt
  3. +1 −1 chapter2.txt
View
@@ -1,6 +1,5 @@
On Ubuntu, you need (at least) these packages:
- epstool
pstoedit
pygmentize
docbook2ps
View
@@ -367,7 +367,9 @@ Memory leaks are one thing, but 0MQ is quite finicky about how you exit an appli
The 0MQ objects we need to worry about are messages, sockets, and contexts. Luckily it's quite simple, at least in simple programs:
-* Always close a message the moment you are done with it, using {{zmq_msg_close[3]}}.
+* Use {{zmq_send[3]}} and {{zmq_recv[3]}} when you can, it avoids the need to work with zmq_msg_t objects.
+
+* If you do use {{zmq_msg_recv[3]}}, always release the received message as soon as you're done with it, by calling {{zmq_msg_close[3]}}.
* If you are opening and closing a lot of sockets, that's probably a sign you need to redesign your application.
View
@@ -263,7 +263,7 @@ Some other things that are worth knowing about messages:
* A message (single, or multi-part) must fit in memory. If you want to send files of arbitrary sizes, you should break them into pieces and send each piece as separate single-part messages. //Using multi-part data will not reduce memory consumption.//
-* You must call {{zmq_msg_close[3]}} when finished with a message, in languages that don't automatically destroy objects when a scope closes.
+* You must call {{zmq_msg_close[3]}} when finished with a received message, in languages that don't automatically destroy objects when a scope closes. You don't call this method after sending a message.
And to be repetitive, do not use {{zmq_msg_init_data[3]}} yet. This is a zero-copy method and guaranteed to create trouble for you. There are far more important things to learn about 0MQ before you start to worry about shaving off microseconds.

0 comments on commit b67473b

Please sign in to comment.