Questions tagged [destroy]

In object-oriented languages, objects need to be destroyed after their creation to free memory. Destruction can however have a broader meaning. Sometimes, destruction means that resources must be freed or that files must be deleted.

In object-oriented languages, objects need to be destroyed after their creation to free memory. This is not necessarily something that a programmer needs to explicitly instruct. Garbage collected languages such as Java or Python take care of object destruction for you. Other languages such as C++ require the programer to destroy objects explicitly.

Destruction can however have a broader meaning. Sometimes, destruction means that resources must be freed or that files must be deleted.

982 questions
263
votes
7 answers

Difference between Destroy and Delete

What is the difference between @model.destroy and @model.delete For example: Model.find_by(col: "foo").destroy_all //and Model.find_by(col: "foo").delete_all Does it really matter if I use the one or the other?
Saggex
  • 3,390
  • 3
  • 22
  • 37
136
votes
6 answers

How to destroy an object?

As far as I know (which is very little) , there are two ways, given: $var = new object() Then: // Method 1: Set to null $var = null; // Method 2: Unset unset($var); Other better method? Am I splitting hairs here?
PandemoniumSyndicate
  • 2,855
  • 6
  • 29
  • 49
88
votes
5 answers

How to destroy a JavaScript object?

Recently, I came across one of my application which consumes too much memory and increasing by 10 MB/sec. So, I like to know how to destroy JavaScript object and variables so memory consumption stays down and my FF can't get destroyed. I am calling…
Amit Shah
  • 1,117
  • 1
  • 9
  • 11
81
votes
8 answers

Remove duplicate records based on multiple columns?

I'm using Heroku to host my Ruby on Rails application and for one reason or another, I may have some duplicate rows. Is there a way to delete duplicate records based on 2 or more criteria but keep just 1 record of that duplicate collection? In my…
sergserg
  • 21,716
  • 41
  • 129
  • 182
70
votes
3 answers

Destroying a specific session in Code Igniter

I want to be able to log users out of my app built in Code Igniter. I know how to end an active local session: $this->session->sess_destroy(); But how can I destroy a session that was started on another computer and thereby log a user out of their…
frosty
  • 4,741
  • 4
  • 17
  • 9
60
votes
4 answers

Destroying a Postgres DB on Heroku

I want to destroy the database but I'm not sure what the command would be. Does anyone know how to do this?
captDaylight
  • 2,224
  • 4
  • 31
  • 42
60
votes
1 answer

What is "destroying operator delete" in C++20?

C++20 introduced "destroying operator delete": new overloads of operator delete that take a tag-type std::destroying_delete_t parameter. What exactly is this and when is it useful?
60
votes
4 answers

Why does super.onDestroy() in java Android goes on top in destructors?

According to which logic does super.onDestroy(); in destructors goes on top? For example: protected void onDestroy() { super.onDestroy(); releaseMediaPlayer(); } and not: protected void onDestroy() { …
Vassilis
  • 2,878
  • 1
  • 28
  • 43
54
votes
7 answers

How to execute code before app exit flutter

I want to detect when a user quit my app and execute some code before but I don't know how to do this. I tried to use this package: https://pub.dev/packages/flutter_lifecycle_state but I have this error:…
luc
  • 1,301
  • 2
  • 14
  • 30
44
votes
5 answers

Tkinter example code for multiple windows, why won't buttons load correctly?

I am writing a program which should: Open a window with the press of a button. Close the newly opened window with the press of another button. I'm using classes so I can insert the code into a larger program later. However, I can't get my buttons…
ADB
  • 1,210
  • 4
  • 15
  • 23
30
votes
5 answers

Cannot reinitialise DataTable - dynamic data for datatable

I have a datatable showing all employees. It is working fine for all employees on document.ready. I have a select tag containing the type of employees like 'project_manager' & 'team_leader' , and on change of employee type I am calling a function…
Pramod
  • 2,828
  • 6
  • 31
  • 40
27
votes
2 answers

ActiveRecord 'destroy' method returns a boolean value in Ruby on Rails?

I am using Ruby on Rails 3 and I would like to know what type of return will have the following code: @user.destroy I need that to handle cases on success and fault in someway like this: if @user.destroy puts "True" else puts "false" end Is it…
user502052
  • 14,803
  • 30
  • 109
  • 188
26
votes
6 answers

when is a spring beans destroy-method called?

I have put a sysout statement in the "destroy-method" for a bean. When i run a sample code, the sysout is not getting output. Does that mean the destroy-method is not getting called ? The Test Class: package spring.test; import…
java_geek
  • 17,585
  • 30
  • 91
  • 113
23
votes
7 answers

Are reference attributes destroyed when class is destroyed in C++?

Suppose I have a C++ class with an attribute that is a reference: class ClassB { ClassA &ref; public: ClassB(ClassA &_ref); } Of course, the constructor is defined this way: ClassB::ClassB(ClassA &_ref) : ref(_ref) { /* ... */ } My…
Genba
  • 854
  • 2
  • 10
  • 19
22
votes
5 answers

Re-initialize or destroy Bootstrap datepicker dynamically

Is there a way to destroy the Bootstrap datepicker dynamically updating its options like format, beforeShowDay, etc.? I know that the jQuery UI datepicker has a destroy method but Bootstrap's has not. It only has the .('remove') method but its not…
dan
  • 990
  • 1
  • 14
  • 22
1
2 3
65 66