CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

freeing objects in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 17, 2020, 06:05
Default freeing objects in OpenFOAM
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Foamers:

In a function I declared an instance of DynamicList. Textbook C++ told me that I should be deallocating this in the class destructor or, when it is declared in a function, I should delete it once it is not used anymore.

However, I don't see anything to that effect. The question is, do I have to do this, or these are being done "ad hoc" somewhere in the OpenFOAM code?

Thanks in advance, Ed.
Gerry Kan is offline   Reply With Quote

Old   July 19, 2020, 14:10
Default
  #2
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Heap memory is deallocated in the destructor of List class which DinamicList class is derived from. Take a look:
template<class T>
Code:
 Foam::List<T>::~List()
 {
     if (this->v_)
     {
         delete[] this->v_;
     }
 }
Zeppo is offline   Reply With Quote

Old   July 20, 2020, 02:41
Default
  #3
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Dear Sergei:

It looks like I still have to learn how to traverse the OpenFOAM object inheritance tree. Thank you very much for pointing that out and this put my mind at ease with your response.

Sincerely yours, Gerry.
Gerry Kan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transforming Multi objects in Fluent to openfoam??? umdj@keri.re.kr OpenFOAM 0 June 21, 2016 05:05
OpenFOAM Training Beijing 22-26 Aug 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 May 3, 2016 04:57
OpenFOAM Foundation Releases OpenFOAM v2.3.0 opencfd OpenFOAM Announcements from OpenFOAM Foundation 3 December 23, 2014 03:43
OpenFOAM Foundation releases OpenFOAM 2.2.2 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 October 14, 2013 07:18
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 05:56


All times are GMT -4. The time now is 21:13.