Thread Subject: Clear existing objects

Subject: Clear existing objects

From: Stefan

Date: 1 Oct, 2008 07:37:01

Message: 1 of 4

Hello,

I am debugging some object oriented code.
After exiting the debug mode somewhere in my function I want to get rid of existing objects, so that I can modifiy my class definition files.
I'm using the commands "clear all" and "clear classes" but "clear alls" doesn't delete all objects.

The existing objects can't be seen in the workspace.
How can I delete these objects?


Here is the response to my clear commands:


>> clear all
>> clear classes
Warning: Objects of 'tdTracePacket' class exist. Cannot clear this class or any of its super-classes.
Warning: Objects of 'tdStation' class exist. Cannot clear this class or any of its super-classes.
Warning: Objects of 'tdChannelAxes' class exist. Cannot clear this class or any of its super-classes.
Warning: Objects of 'smUnit' class exist. Cannot clear this class or any of its super-classes.
Warning: Objects of 'tdTrace' class exist. Cannot clear this class or any of its super-classes.
Warning: Objects of uitools.uimodemanager class exist - not clearing this class
or any of its super-classes
Warning: Objects of uitools.uimode class exist - not clearing this class
or any of its super-classes
Warning: Objects of graphics.datacursormanager class exist - not clearing this class
or any of its super-classes
Warning: The following classes still have existing instances that cannot be cleared:
sm_module (77 instances)
sm_flowList (5 instances)
database (1 instance)
sm_flowModule (10 instances)
dbtbx (1 instance)

>>


Thank's
  Stefan.

Subject: Clear existing objects

From: Martin

Date: 3 Nov, 2008 07:44:06

Message: 2 of 4

I have encountered the same problem when using the Matlab Database toolbox (which is largely based on objects). When I run my code, these objects seem to slowly fill up my RAM until I get an outOfMemory error. If I try a 'clear all', the RAM is just as full, and if I try 'pack', I get errors of this kind:

Warning: com.mathworks.toolbox.database.databaseConnect@baaea8 is not serializable
Warning: oracle.jdbc.driver.T4CConnection@20a239 is not serializable
Warning: Could not serialize object: oracle.sql.BLOB@1d2acaf
java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection

The objects disappear and the RAM is cleared when if I do a restart of Matlab. Sorry that I have no fix for your problem, Stefan - I'm just hoping someone else has.

Martin

Subject: Clear existing objects

From: Steven Lord

Date: 3 Nov, 2008 15:06:20

Message: 3 of 4


"Martin " <martin.hansen.removethis@breivoll.andthis.no> wrote in message
news:gema46$7lc$1@fred.mathworks.com...
>I have encountered the same problem when using the Matlab Database toolbox
>(which is largely based on objects). When I run my code, these objects seem
>to slowly fill up my RAM until I get an outOfMemory error. If I try a
>'clear all', the RAM is just as full, and if I try 'pack', I get errors of
>this kind:

Make sure you CLOSE the objects created by Database Toolbox before trying to
CLEAR them, or you could potentially be leaving part of the connection
hanging.

http://www.mathworks.com/access/helpdesk/help/toolbox/database/ug/close.html

Once you CLOSE them, you should be able to CLEAR them just like any other
variable.

As for PACK, as it states in its description, it temporarily saves your
workspace data into a file (it serializes the variables.)

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pack.html

> Warning: com.mathworks.toolbox.database.databaseConnect@baaea8 is not
> serializable
> Warning: oracle.jdbc.driver.T4CConnection@20a239 is not serializable
> Warning: Could not serialize object: oracle.sql.BLOB@1d2acaf
> java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection

It doesn't make sense to serialize a connection to a database (what if that
database was no longer available the next time you loaded that object?)
Therefore, the ability to do so has not been implemented (or it has been
implemented to throw an exception, in the case of the Java
oracle.jdbc.driver.T4CConnnection class.)

--
Steve Lord
slord@mathworks.com

Subject: Clear existing objects

From: Steffen

Date: 18 Nov, 2008 10:50:17

Message: 4 of 4

"Steven Lord" <slord@mathworks.com> wrote in message <gen41c$fcg$1@fred.mathworks.com>...
>
> "Martin " <martin.hansen.removethis@breivoll.andthis.no> wrote in message
> news:gema46$7lc$1@fred.mathworks.com...
> >I have encountered the same problem when using the Matlab Database toolbox
> >(which is largely based on objects). When I run my code, these objects seem
> >to slowly fill up my RAM until I get an outOfMemory error. If I try a
> >'clear all', the RAM is just as full, and if I try 'pack', I get errors of
> >this kind:
>
> Make sure you CLOSE the objects created by Database Toolbox before trying to
> CLEAR them, or you could potentially be leaving part of the connection
> hanging.
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/database/ug/close.html
>
> Once you CLOSE them, you should be able to CLEAR them just like any other
> variable.
>
> As for PACK, as it states in its description, it temporarily saves your
> workspace data into a file (it serializes the variables.)
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pack.html
>
> > Warning: com.mathworks.toolbox.database.databaseConnect@baaea8 is not
> > serializable
> > Warning: oracle.jdbc.driver.T4CConnection@20a239 is not serializable
> > Warning: Could not serialize object: oracle.sql.BLOB@1d2acaf
> > java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
>
> It doesn't make sense to serialize a connection to a database (what if that
> database was no longer available the next time you loaded that object?)
> Therefore, the ability to do so has not been implemented (or it has been
> implemented to throw an exception, in the case of the Java
> oracle.jdbc.driver.T4CConnnection class.)
>
> --
> Steve Lord
> slord@mathworks.com
>

Hi Steven,

this only applies to database objects. Whatabout self-defined objects. I got the same error message (see first message in this thread) for user defined classes and objects. Is there a way to define a close function for those objects?

BR,
Steffen

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
memory leak Martin 3 Nov, 2008 02:45:11
database Martin 3 Nov, 2008 02:45:11
object Martin 3 Nov, 2008 02:45:11
rssFeed for this Thread

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.

Contact us at files@mathworks.com