CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

Crashes and suspicious memory management

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2016, 21:54
Default Crashes and suspicious memory management
  #1
New Member
 
Data C
Join Date: Feb 2016
Posts: 8
Rep Power: 10
LetsCFD is on a distinguished road
During the destruction of many classes, you can see something like this:

if (MG_PreSmooth!=NULL) delete [] MG_PreSmooth;

But the delete [] MG_PreSmooth also happens somewhere else in the class before the destruction. I guess the author may assume delete [] MG_PreSmooth will make the MG_PreSmooth become NULL. So, the destruction could skip it.

But the reality is that delete [] will never make a pointer NULL. So, the destruction will attempt to delete [] MG_PreSmooth again and it may destroy some other data.

The "new" and "delete" should be avoided as much as possible to favor the smart pointer management such as std::unique_ptr.

Right now, I have a lot of delete[] related crashes.
LetsCFD is offline   Reply With Quote

Old   May 24, 2016, 22:39
Default
  #2
hlk
Senior Member
 
Heather Kline
Join Date: Jun 2013
Posts: 309
Rep Power: 13
hlk is on a distinguished road
Quote:
Originally Posted by LetsCFD View Post
During the destruction of many classes, you can see something like this:

if (MG_PreSmooth!=NULL) delete [] MG_PreSmooth;

But the delete [] MG_PreSmooth also happens somewhere else in the class before the destruction. I guess the author may assume delete [] MG_PreSmooth will make the MG_PreSmooth become NULL. So, the destruction could skip it.

But the reality is that delete [] will never make a pointer NULL. So, the destruction will attempt to delete [] MG_PreSmooth again and it may destroy some other data.

The "new" and "delete" should be avoided as much as possible to favor the smart pointer management such as std::unique_ptr.

Right now, I have a lot of delete[] related crashes.
Please check out the most recent release - although we did not see memory related crashes in general, many issues similar to this have been fixed in the past couple of months. Please do let us know if you continue to see memory issues with the more recent code.
hlk 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



All times are GMT -4. The time now is 14:55.