2002 2003 2004 <2005> 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 | Index | 2002 2003 2004 <2005> 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Standard String |
From: | Andrew Johnson <[email protected]> |
To: | Benjamin Franksen <[email protected]> |
Cc: | [email protected] |
Date: | Wed, 20 Jul 2005 15:02:01 -0500 |
Benjamin Franksen wrote:
how you would implement this record type if all strings become read-only once created.You already answered your question: The string gets regenerated every time. It's a new string, different from the old one. No destructive update of the string is necessary to achieve that.
So every time you process the record, you free() the old string buffer and malloc() at least one new one, if not several as we extend the string? I don't see how that helps us at all, so I'm probably not understanding what you meant.
You have a record (a struct) that contains a string field as a data member. If you say I can't modify the string, and I say I can't move the record in memory, how do I change the value of that string field?
The current EPICS code only allocates memory for database storage at dbLoadRecords() and iocInit() time, for a very good reason: continual allocation and freeing of memory *will* fragment the IOC memory pool into smaller and smaller chunks (we know that from experience, and take some special precautions inside iocCore which you may not be aware of). The vxWorks memory allocator is *particularly* bad when it comes to fragmentation, but even using a better allocator it's not going to be possible to run an IOC for months or even years without rebooting if it's continually churning its memory.
Please remember that we have to be able to run on small footprint systems with 8MB or maybe 16MB of RAM (I think we said 8 at the meeting last week), and there's no virtual memory so no swapping or paging possible on these small IOCs.
- Andrew -- Podiabombastic: The tendency to shoot oneself in the foot.