CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

delete pointer of scalar in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2020, 00:46
Default delete pointer of scalar in OpenFOAM
  #1
Senior Member
 
Mehdi Baba Mehdi
Join Date: Jan 2011
Posts: 158
Rep Power: 15
mb.pejvak is on a distinguished road
I created dynamic arrays of scalar in openfoam like this
Code:
int num = 10;
scalar myScalar = new scalar[num];

and then I want to delete the pointer of array like this
Code:
delete[] myScalar;

but it seems for scalar class, delete operator has not been defined. So my question is how I should delete pointer of array to prevent memory leak.
mb.pejvak is offline   Reply With Quote

Old   April 13, 2020, 10:09
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,675
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
To call delete you normally would need to allocate it using something like:

Code:
scalar *myScalar = new scalar[num];

Or does that not fix the issue?
LuckyTran is offline   Reply With Quote

Reply

Tags
delete, memory leak, openfoam, scalar array


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
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
OpenFOAM course for beginners Jibran OpenFOAM Announcements from Other Sources 2 November 4, 2019 08:51
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 13:36
New OpenFOAM Forum Structure jola OpenFOAM 2 October 19, 2011 06:55
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25


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