[zeromq-dev] Memory leak in recv() in Java client

gonzalo diethelm gdiethelm at dcv.cl
Tue May 11 20:00:28 CEST 2010


> > Taking a look at JNIEXPORT jbyteArray JNICALL
> > Java_org_zeromq_ZMQ_00024Socket_recv (JNIEnv *env, jobject obj,
jlong
> > flags) in Socket.cpp, I noticed that the zmq_msg_t message was never
> > cleaned up, so I added a zmq_close_message(&message) right before
> > returning, and now there is no growth in the consumer memory size.
Here
> > is the change, with a bit of context:
> >
> > 346    env->SetByteArrayRegion (data, 0, sz, (jbyte*) pd);
> > 347
> > 348    zmq_msg_close(&message);
> > 349
> > 350    return data;
> >
> > Since I've only just (in the last week) started playing with 0MQ,
I'm
> > not 100% confident that this is the right "fix", so would appreciate
> > some feedback from someone with a bit more knowledge.
> 
> Yes. You are right. The message is never deallocated. I've committed
the
> fix.
> 
> Thanks!

Great catch Jon, thank you very much.

-- 
Gonzalo Diethelm



----------------------------------------- 
Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 




More information about the zeromq-dev mailing list