cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
David_Burnham
Super User (Alumni)

Deleting Objects in v15

In JSL I can define a class and use it as a template to instantiate objects.

 

How do I delete the object?

 

I've been using the message deleteClass, assuming its a slight misnomer and really it's deleting the object.

 

But in version 15 it really does seem to delete the class.  Once I use the message I'm unable to create any further instances of the class.

 

I can use a delete message but I think its just an alias for deleteClass and I have the same problem.

 

Is delete class really intended to wipe out the entire class definition?  If so, what is the correct way of deleting the object?

 

Here is a simple test script:

 

names default to here(1);

defineClass("MyClass",{
	_value = .,
	_init_ = method({value},
		_value = value;
	),
	getValue = method({},
		return(_value)
	)
});

// this works
obj = newObject( MyClass( 10 ) );
show(obj:getvalue);

// this works 
obj = newObject( MyClass( 20 ) );
show(obj:getvalue);

// there should be no harm deleting
// an object once I am finished with it
obj<<delete;

// but this now fails ...
obj = newObject( MyClass( 30 ) );
show(obj:getvalue);

 

-Dave
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Deleting Objects in v15

I don't understand how to use it either. I think you don't need it:

Define Class(
	"aa",
	{_init_ = Method( {a}, this:b = a ), //
	x=1, //
	m1 = Method( {a, b}, a * b )}
);

// 
lcaa42 = New Object( aa(42) );

lcaa42:x= Run Program(//
		Executable( "PING.EXE" ), //
		Options( {"-n 50", "localhost"} ), //
		ReadFunction(
			Function( {this},
				write(this << read);
			)
		)
	);
	
wait(5); // report about 5 of the 50 pings to the log

// this will destroy the old object and replace it with a
// new one. The log will report the RunProgram object was
// destroyed; there may be a more clever way to witness the
// destruction...best I could come up with...
lcaa42 = New Object( aa(42.1) ); // the old one is gone
lcaa43 = New Object( aa(43) ); // the class still works
show(lcaa42:b,lcaa43:b); // 42.1,43
Show Classes();

Pinging v1-PC [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
The external program was producing output when the RunProgram object was destroyed.
Use a JSL variable to hold the RunProgram object.
Optionally, send messages to the variable to manage the object's lifetime.

lcaa42:b = 42.1;
lcaa43:b = 43;
// Class aa

_init_ = Method( {a}, this:b = a );
m1 = Method( {a, b}, a * b );
x = 1;

This shows the first object was deleted by assigning a new value to the variable holding it.

 

If other variables are copied (not cloned)

lcaa42b=lcaa42;

then all the copies must be cleared to destroy the object.

lcaa42b=0;
lcaa42=0;

 

@EvanMcCorkle 

Craige

View solution in original post

5 REPLIES 5
pmroz
Super User

Re: Deleting Objects in v15

Does this work: obj = .;

David_Burnham
Super User (Alumni)

Re: Deleting Objects in v15

I don't know.

Before it was possible to "define classes" I created them using namespaces.

For namespaces this doesn't work i.e. setting the variable to missing is not the same as deleting the namespace.

 

ns = newNamespace("xyz");
ns:a = 10;

ns = .;

show namespaces();
-Dave
Craige_Hales
Super User

Re: Deleting Objects in v15

I don't understand how to use it either. I think you don't need it:

Define Class(
	"aa",
	{_init_ = Method( {a}, this:b = a ), //
	x=1, //
	m1 = Method( {a, b}, a * b )}
);

// 
lcaa42 = New Object( aa(42) );

lcaa42:x= Run Program(//
		Executable( "PING.EXE" ), //
		Options( {"-n 50", "localhost"} ), //
		ReadFunction(
			Function( {this},
				write(this << read);
			)
		)
	);
	
wait(5); // report about 5 of the 50 pings to the log

// this will destroy the old object and replace it with a
// new one. The log will report the RunProgram object was
// destroyed; there may be a more clever way to witness the
// destruction...best I could come up with...
lcaa42 = New Object( aa(42.1) ); // the old one is gone
lcaa43 = New Object( aa(43) ); // the class still works
show(lcaa42:b,lcaa43:b); // 42.1,43
Show Classes();

Pinging v1-PC [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
The external program was producing output when the RunProgram object was destroyed.
Use a JSL variable to hold the RunProgram object.
Optionally, send messages to the variable to manage the object's lifetime.

lcaa42:b = 42.1;
lcaa43:b = 43;
// Class aa

_init_ = Method( {a}, this:b = a );
m1 = Method( {a, b}, a * b );
x = 1;

This shows the first object was deleted by assigning a new value to the variable holding it.

 

If other variables are copied (not cloned)

lcaa42b=lcaa42;

then all the copies must be cleared to destroy the object.

lcaa42b=0;
lcaa42=0;

 

@EvanMcCorkle 

Craige
vince_faller
Super User (Alumni)

Re: Deleting Objects in v15

It seems like it's overwriting it if you just overwrite the variable.  I ran 

 

Names Default To Here( 1 );
Define Class(
	"Test",
	nObs = 20;
	addition = Method( {x, y},
		(x + y) * nObs
	);
	append = Method( {a, b},
		Char( a ) || " + " || Char( b )
	);
);

for(i=1, i<=1000000, i++, 
	clref = New Object( Test() );
);

delete symbols(clref);

While looking at the memory usage of JMP and it didn't really move.  I would expect if it wasn't actually overwriting it I'd see memory go up if I have a million of them.  

 

 

Vince Faller - Predictum
David_Burnham
Super User (Alumni)

Re: Deleting Objects in v15

Thanks everyone, I think the evidence if clear that reassigning an object variable destroys the object rather than leaving it as an orphan in memory,

-Dave

Recommended Articles