EPICS Home

Experimental Physics and Industrial Control System


 
1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: waveform record: how its VAL get data? any potential memory leak? ...
From: "Hu, Yong" <[email protected]>
To: "'Jack Smith'" <[email protected]>, "[email protected]" <[email protected]>
Date: Fri, 26 Oct 2012 13:28:53 +0000
Hi,

I think I can answer part of your questions (I am using base-3.14.12.2 and related documents).

1. paddr->pfield = prec->bptr in the function cvt_dbaddr() in waveformRecord.c makes buffer pointer data to VAL. I guess the reason why we need to set the field NORD in the device support is that Channel Access clients need to know some information about this array-type record, specially the number of elements (no_elements), through the routine get_array_info() in waveformRecord.c (*no_elements =  prec->nord;). For example, when an CA client issues ca_get, the request is mapped to dbGetField inside the IOC side. Check out the functions dbGetField() and dbGet() in dbAccess.c and you will get the idea why we need to set field NORD. Actually if you don't set NORD in the device support, you still can get the waveform data by the IOC shell command dbgf "waveform-record". But the CA clients will get all-zero data.  

2. I think all memory allocated in that IOC should be released if the IOC is killed. One easy verification is that you configure NELM of waveform record to a very large number (i.e. 10M or higher. remember to setup EPICS_CA_MAX_ARRAY_BYTES on both IOC side and CA client side), start the IOC and then kill it later. Use "top" or "free -m" or other tools to monitor the memory changes. 

3. In EPICS Application Developer's Guide, it says DBF_NOACCESS fields are for private use by record processing routines. So, DBF_NOACCESS doesn't mean no access to the field. Whether a field is accessible by CA client depends on the definition of special(special_value) of that field in xxxRecord.dbd. In waveformRecord.dbd, the special_value is SPC_DBADDR for the field VAL and SPC_NOMOD for the field BPTR. SPC_NOMOD means "No external modifications allowed. This value disables external writes to the field, so it can only be set by the record or device support module".  

Hope these answers are helpful.

Good luck,

Yong

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jack Smith
Sent: Thursday, October 25, 2012 11:31 PM
To: [email protected]
Subject: waveform record: how its VAL get data? any potential memory leak? ...

Hello everyone,

I'm looking through the source code of the waveform record and trying to understand how the it works. A few questions:

1. How does the BPTR field transfer data to VAL? Why do we have to set NORD in the device support?

2.  During the record initialization, there is memory allocation by callocMustSucceed( ). I remember some programming experts claim that malloc (or new) must be paired with free (or delete) in a program to prevent memory leak. If that is true, how should we deal with this allocated memory in the lower level such as device support or driver support to prevent memory leak? If I type "exit" to kill a Linux IOC, will the memory allocated to the waveform record be released automatically so that there is actually no memory leak problem?

3. When I look at waveformRecord.dbd, the field type of both VAL and BPTR is DBF_NOACCES which I guess means no access to this field from the database outside. It's true that I can't camonitor waveform-record.BPTR, but obviously we can camonitor waveform-record(.VAL). So, why does the DBF_NOACCES affect the VAL field and the BPTR differently? What kind of magic makes VAL accessible while BPTR inaccessble?

Thanks,

J.S.


References:
waveform record: how its VAL get data? any potential memory leak? ... Jack Smith

Navigate by Date:
Prev: Re: what are your definitions of softIOC and soft record? Ralph Lange
Next: Re: waveform record: how its VAL get data? any potential memory leak? ... Michael Davidsaver
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: waveform record: how its VAL get data? any potential memory leak? ... Jack Smith
Next: Re: waveform record: how its VAL get data? any potential memory leak? ... Michael Davidsaver
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024