Questions tagged [finalizer]

A finalizer is a special method in an object-oriented language that is executed when an object is garbage collected.

A finalizer is a special method in an object-oriented language that is executed when an object is garbage collected.

Java Documentation (Javadoc) defines the moment when the finalizer is invoked as:

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

However, this may never happen in the life of a program if the object is always accessible. Due to the lack of programmer control over their execution, it is usually recommended to avoid finalizers for any but the most trivial operations.

442 questions
0
votes
1 answer

Cleanly shutting down a DLL's Static events in a host I don't control

Does the following psuedo code accomplish my goal of cleaning up after myself when my DLL is being hosted by code I don't control? More specifically, how do I clean up my objects created in my static constructor? Do I need to suppress Finalize in…
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
-1
votes
1 answer

Why finalizer is never called?

var p = &sync.Pool{ New: func() interface{} { return &serveconn{} }, } func newServeConn() *serveconn { sc := p.Get().(*serveconn) runtime.SetFinalizer(sc, (*serveconn).finalize) fmt.Println(sc, "SetFinalizer") …
gopher
  • 35
  • 2
-1
votes
1 answer

Libgdx ShapeRenderer lag

I have created a simple game for android using the LibGDX framework. Unfortunately the game sometimes begins to stutter for a brief moment, which ruins the experience. I figured this might be due to garbage collection so I had a look at the memory…
-1
votes
1 answer

Use of Finalizers to free up memory

I'm new to C++/CLI, and would like a clarification on memory free up. Imagine a scenario, where : sampleServer srv = new sampleServer() while(true) { ABC newObject = srv.getItem(); } ABC^ sampleServer::getItem(){ return gcnew ABC(//LIST OF…
user1173240
  • 1,455
  • 2
  • 23
  • 50
-1
votes
1 answer

Access violation to unmanaged memory from finalizer

I tried to clean up memory of unmanaged classes from c++/cli finalizer and it gave me AcessViolation error. I do something like this: MyClass::!MyClass() { if(_unmanaged) { _unmanaged->Delete(); _unmanaged = 0; } } Could anyone…
-2
votes
1 answer

Java Object.finalize() vs. C# IDisposable

I have extensive Java experience and know why finalize() is scheduled for a removal soon. On the other hand, my knowledge about C# is skin-deep - I am more or less aware about what features it offers on the abstract level, but no real experience to…
Turin
  • 2,208
  • 15
  • 23
-2
votes
1 answer

Android exception finalizer

I've been receiving this error and I can't figure out why I have. It doesn't cause the app to crash but I'm not sure if it is affecting my app or not. 05-03 16:29:20.962 31355-31366/com.example.apthagreat.faf E/System﹕ Uncaught exception thrown by…
Allen Perry
  • 191
  • 1
  • 8
1 2 3
29
30