Opposite of New()?

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Opposite of New()?

Post by Barbie »

Hi out there,

I am looking for Free() or Destroy() or similar to destroy an object that was created by New(). Or does UT have a garbage collector for this? (And Wiki is down again...)

Code: Select all

class TDLLSB extends Object;
...
DLLSB = new class'TDLLSB';
...
DLLSB.Free(); // <- something like this
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Shadow
Masterful
Posts: 743
Joined: Tue Jan 29, 2008 12:00 am
Personal rank: Mad Carpenter
Location: Germany
Contact:

Re: Opposite of New()?

Post by Shadow »

UObjects are destroyed with the function YourObject->ConditionalDestroy(), Actors are destroyed with with ULevel->DestroyActor(yourActor*)
Image
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: Opposite of New()?

Post by Wormbo »

UnrealScript is a garbage-collected language for everything that is not an Actor. In other words, you cannot destroy non-actor objects in any effective way. To get rid of them, clear all references to them and let the garbage collector do its job. The GC either runs on map change or when explicitly telling it to do its job through console command "obj garbage". Note that the Unreal Engine's garbage collector is a stop-the-world implementation prior to Unreal Engine 3.
User avatar
Shadow
Masterful
Posts: 743
Joined: Tue Jan 29, 2008 12:00 am
Personal rank: Mad Carpenter
Location: Germany
Contact:

Re: Opposite of New()?

Post by Shadow »

Oh.. my bad, it was about uscript -_-
Image
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Opposite of New()?

Post by sektor2111 »

Objects, huh ?
It's not much easier some Info with replicated things rather than reinventing wheel ?
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Opposite of New()?

Post by Barbie »

Thanks for the replies - so I will leave old stuff untouched then.

The reason for my question was that I replaced some static arrays by double linked lists (similar to class Object.ListItem) because of unknown item count while developing. Deleting list items may occur, but not often in the areas I use these lists.
(And yes, I know what cache misses are. ;o))
<edit>PS: the last time I messed around with linked lists was with Turbo Pascal and DOS...</edit>

Cheers,
Barbie
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
UTX
Skilled
Posts: 214
Joined: Fri Aug 28, 2015 3:39 am

Re: Opposite of New()?

Post by UTX »

It's Old(), duh.
User avatar
papercoffee
Godlike
Posts: 10447
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Opposite of New()?

Post by papercoffee »

UTX wrote:It's Old(), duh.
Don't do this ...you will anger the Gods of U-script.


:mrgreen:
Post Reply