Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
java memory leak in matlab

Subject: java memory leak in matlab

From: Corbin Holland

Date: 5 Jun, 2009 18:17:17

Message: 1 of 2

I was reading http://undocumentedmatlab.com/ today and I came across the snippet below where the author shows that setting a matlab function as a java object callback directly to the java object itself is a memory leak. I was wondering if anyone out there could provide an explanation as to why that is? Here is the snippet:

jb = javax.swing.JButton;
jbh = handle(jb,'CallbackProperties');
% or for an existing uicontrol: jbh = findjobj(hButton);
set(jbh, 'ActionPerformedCallback',@myCallbackFcn) % ok!
set(jb, 'ActionPerformedCallback',@myCallbackFcn) % bad! memory leak

Subject: java memory leak in matlab

From: Yair Altman

Date: 9 Mar, 2010 09:44:03

Message: 2 of 2

"Corbin Holland" <cholland.nospam@opticalsciences.com> wrote in message <h0bnfd$kr7$1@fred.mathworks.com>...
> I was reading http://undocumentedmatlab.com/ today and I came across the snippet below where the author shows that setting a matlab function as a java object callback directly to the java object itself is a memory leak. I was wondering if anyone out there could provide an explanation as to why that is? Here is the snippet:
>
> jb = javax.swing.JButton;
> jbh = handle(jb,'CallbackProperties');
> % or for an existing uicontrol: jbh = findjobj(hButton);
> set(jbh, 'ActionPerformedCallback',@myCallbackFcn) % ok!
> set(jb, 'ActionPerformedCallback',@myCallbackFcn) % bad! memory leak


Better late than never I guess...
http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-7989

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us