Liberate any resources held by self before the memory holding self is freed

This method is invoked by the GC during a garbage collection when self is no longer referenced. It can also be called by the user. Its implementation must be planned accordingly and ensure that it may be invoked more than once.

The object are not finialized in a topological order, it is safe for this method to use attributes of this instances, unless theses attributes are finalizable as well because they may have been finalized already.

Property definitions

core $ Finalizable :: finalize
	# Liberate any resources held by `self` before the memory holding `self` is freed
	#
	# This method is invoked by the GC during a garbage collection when `self`
	# is no longer referenced. It can also be called by the user. Its implementation
	# must be planned accordingly and ensure that it may be invoked more than once.
	#
	# The object are not finialized in a topological order, it is safe for this method
	# to use attributes of this instances, unless theses attributes are finalizable as well
	# because they may have been finalized already.
	fun finalize do end
lib/core/gc.nit:28,2--37,20

core $ FileStat :: finalize
	redef fun finalize
	do
		if not finalized then
			stat.free
			finalized = true
		end
	end
lib/core/file.nit:778,2--784,4

core $ FinalizableOnce :: finalize
	redef fun finalize
	do
		if finalized then return

		finalize_once
		finalized = true
	end
lib/core/gc.nit:52,2--58,4

pthreads $ Thread :: finalize
	redef fun finalize
	do
		if native == null then return
		native.free
		native = null
	end
lib/pthreads/pthreads.nit:351,2--356,4

pthreads $ Mutex :: finalize
	redef fun finalize
	do
		var native = self.native
		if native != null then
			native.destroy
			native.free
		end
		self.native = null
	end
lib/pthreads/pthreads.nit:415,2--423,4

pthreads $ Barrier :: finalize
	redef fun finalize
	do
		var cond = self.cond
		if cond != null then
			cond.destroy
			cond.free
		end
		self.cond = null
	end
lib/pthreads/pthreads.nit:473,2--481,4

sdl2 $ SDL :: finalize
	redef fun finalize do if was_initialized then quit
lib/sdl2/sdl2_base.nit:72,2--51

core $ Regex :: finalize
	redef fun finalize
	do
		var native = self.native
		if native != null then
			native.regfree
			native.free
			self.native = null

			if native_match_is_init then
				self.native_match.free
			end
		end
	end
lib/core/re.nit:251,2--263,4

linux :: ui $ Control :: finalize
	redef fun finalize
	do
		var native = native
		if not native.address_is_null then native.destroy
	end
lib/linux/ui.nit:111,2--115,4

android :: ui $ Button :: finalize
	redef fun finalize do native.delete_global_ref
lib/android/ui/ui.nit:325,2--47

core $ U16String :: finalize
	redef fun finalize do uchar_string.free
lib/core/text/u16_string.nit:141,2--40