Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Callback Cross close function

Subject: Callback Cross close function

From: Luca Cerone

Date: 13 May, 2008 15:11:44

Message: 1 of 3

Hi,
I'm developing a compiled GUI application.
It works fine, but I have a problem:
I can't succeed in making the program to free memory when i
close it clicking on the X (cross) button of my application.

How can I write a callback for the X button?
How can I deallocate all memories, destroy all classes and
free memory (is a clear all enough before of returning?)
If you could help me, I would be very grateful!
Thank you very much in advance!!! -Luca-

Subject: Re: Callback Cross close function

From: helper

Date: 13 May, 2008 16:21:04

Message: 2 of 3

"Luca Cerone" <cerone@to-see.it> wrote in message
<g0cb3g$17m$1@fred.mathworks.com>...
> Hi,
> I'm developing a compiled GUI application.
> It works fine, but I have a problem:
> I can't succeed in making the program to free memory when
i
> close it clicking on the X (cross) button of my
application.
>
> How can I write a callback for the X button?
> How can I deallocate all memories, destroy all classes and
> free memory (is a clear all enough before of returning?)
> If you could help me, I would be very grateful!
> Thank you very much in advance!!! -Luca-

To start with, use the "CloseRequestFcn" of the figure to
specify a callback function for whenever the figure is
requested to close (including using the X button). Note
that at the end of this function, use the DELETE function
to actually delete the figure.

As far as I know, CLEAR ALL is unnecessary to clear
variables from memory. Having the executable quit should
be enough to handle this.

However, things such as timers, serial objects, and OOP
classes need to be carefully considered during their
creation to ensure the appropriate cleanup and deletion
occurs during the "CloseRequestFcn". I do not believe
there is any command within MATLAB to automatically cleanup
and delete everything.

Note that the method for "cleaning up" things which require
it are well documented within MATLAB. For example, check
out the documentation for TIMER and SERIAL. They both show
the necessary "cleanup" steps.

Subject: Re: Callback Cross close function

From: Luca Cerone

Date: 13 May, 2008 16:46:05

Message: 3 of 3

> To start with, use the "CloseRequestFcn"
Thanks I just found it on Matlab Help 2 minutes ago ^_^

> As far as I know, CLEAR ALL is unnecessary to clear
> variables from memory. Having the executable quit should
> be enough to handle this.

I don't know why, but even using delete I get a warning say
something about UiOpenFileDialog class that is still exists
and won't be clean up...

> Note that the method for "cleaning up" things which require
> it are well documented within MATLAB. For example, check
> out the documentation for TIMER and SERIAL. They both show
> the necessary "cleanup" steps.

I'll try looking for Cleanup in Matlab Help (I'm sorry if I
ask something stupid, but the fact is that for a non-english
speaker, sometimes it's difficult to use the right wordkey
for search!)

Thank you very much in advance!
Hope to see you soon!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
deallocate Luca Cerone 13 May, 2008 11:15:11
memory Luca Cerone 13 May, 2008 11:15:11
gui Luca Cerone 13 May, 2008 11:15:11
clear Luca Cerone 13 May, 2008 11:15:11
classes Luca Cerone 13 May, 2008 11:15:11
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics