CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Dec 13, 2019 5:07 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: __delete question
PostPosted: Sat Mar 18, 2017 10:39 am 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 283
Dears. The pointer passed to delete has to be same tye as type used in __new?

I have an FB called BasicType. And others wich derives from him:

FB BasicType

FB IntegerEx extends BasicType

FB LRealEx extends BasicType

After that I have instantiate via _new IntegerEx and LRealEx and I have store its in an array of BasicTypes.

On FB_exit i delete all array elements via a pointer to BasicType.

I have to delete its as LRealEx or IntegerEx pointers or memory manager knows the memory size to free via the pointer value, and I can delete its as BasicType?

Thanks


Top
   
 Post subject: Re: __delete question
PostPosted: Sat Mar 18, 2017 1:09 pm 
Offline

Joined: Sat Jan 02, 2010 2:05 pm
Posts: 97
Hi Josep,

The ZEN code "delete This;" works in high level languages. This should work in your case too...

The trick here will be knowing if Codesys is capable to go deep enough into your variables to see that the variable you are trying to delete has been allocated previously and moreover it is capable to identify which of the instances has to delete in the memory allocation table.

This will be tricky without memory managing functions (i.e. if you are not capable to see if the memory is being occupied/freed as you wish). I'm not aware of functions like those...

Three thoughts on that:

1. Without functions that allow you to monitor if the memory is getting freed or not the only way to monitor that is to start allocating and freeing memory continuously to see if there is any memory leak that ends up blocking the device. Having a soft plc like TwinCAT would avoid any damage.

2. You can always call a specific method inside the pointer that calls "__Delete this;" or even a specific call for delete passing the right pointer there which should not be needed...

3. Even this is not saying a lot, see: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/9007199391178891.html&id=, it seems the help systems are different from one manufacturer to the other one but at the end those functionalities seem to be the same.

Hope this helps.

_________________
http://www.robotecnik.com - robots, CNC and PLC programming.


Top
   
 Post subject: Re: __delete question
PostPosted: Sun Mar 19, 2017 9:19 am 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 283
Thanks Joan.

It seems that via pointer __delete has to know how much memory has to free (if not how it release memory in case __new(int,100)).

But I have not thougt on outern Fb_exit call (as Beckhoff people explains).


Ostres, Joan, la qüestió de la documentació, a cops cansa...


Top
   
 Post subject: Re: __delete question
PostPosted: Mon Mar 20, 2017 11:48 am 
Offline

Joined: Sat Jan 02, 2010 2:05 pm
Posts: 97
Glad it helped... somehow... :lol:

Si, és força lamentable...

_________________
http://www.robotecnik.com - robots, CNC and PLC programming.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited