-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add reallocMemory to callback functions #122
Comments
Comment by iakovn on 8 Jan 2013 22:59 UTC
His conclusion was that it was such a common source of error (because it is misunderstood) that it shouldn't be used directly. And I have to say, I agree. There is no realloc in C++ neither (if one uses only new and delete). To make a decision on the standard it might be worth too make a poll on which importing environments do not provide "native" realloc vs which FMUs need the functionality. Note that there is even a capability flag "canNotUseMemoryManagementFunctions". |
Modified by rerbacher on 6 Feb 2013 11:07 UTC |
Comment by torstenblochwitz on 7 Feb 2013 14:55 UTC |
Comment by karl.wernersson on 26 Jun 2018 13:56 UTC |
Comment by hansolsson on 6 Jul 2018 12:42 UTC One of the issues Steve Maguire lists is the mix of error code and return value - and the obvious solution he proposes is changing the interface to:
(The idea is that if the resize fails ppv will keep its old value - and that memory block will still be valid; so you can handle errors without the associated risk of having an invalid pointer.) If we extend this to have the old size as input as well (instead of getting it from the memory allocator) we get
which could be implemented inside FMUs using the currently available functions (by doing nothing if same size and otherwise always allocating a new block and copying). That means we have an proposed interface that can already be used and implemented with existing functions - inside an FMU without changing the specification. This simplifies testing of this proposed change - we can see how/whether realloc really makes these FMUs faster compared to the existing functions, and the cost of zeroing the memory - and we could even reallocate and guarantee that newly allocated memory is NUL. The proposed interface also makes it easy to implement reallocation-function in languages where no realloc is available (I also looked at #435), in case we decide to actually provide reallocation-function. Addendum: Unless testing reveals that realloc is significantly faster for FMUs I don't see any reason to have a reallocation-function in the standard. |
Comment by anonymous on 25 Jul 2018 14:00 UTC |
Comment by pierre.mai on 1 Aug 2018 15:04 UTC FMI 2.0
FMI 1.0
As said above, it is not unlikely that a number of FMUs which do not declare that they cannot use the memory management callbacks do in fact still use memory management functionality of the OS without declaring this (since there is no obvious way for testing this). |
Discussion at the FMI Design Meeting in Roanne:
Second poll:
|
Is there still the intention to fix this in FMI 3.0? Introducing a reallocMemory callback function? |
I think this should be addressed when we deal with the lifetime issues and that will have to wait, right? |
@andreas-junghanns : you mean #515, right ?
Well, #511 has target milestone 3.1. I understand that @t-sommer and @pmai consider this possible, right? |
With inlining the structures into the function calls (#821) adding a new function requires new function signatures. Theoretically, we could do that using an additional (alternative?) function, but in our 3.0 discussions, we seemed to avoid this kind of solution. This is why I thought I move this to 4.0. This can of course be changed if a discussion results in us changing our mind. |
Discussion at April 2020 Design Meeting: |
- fmi3CallbackAllocateMemory - fmi3CallbackFreeMemory and attribute "canNotUseMemoryManagementFunctions" see modelica#122
Poll again April 2020 FMI Design Meeting.
|
PR #928 was created and will be merged. |
* Create FMI_Project_news.md * Update according to review * Changes according to review of Thomas Beutlich * Changes proposed by Torsten Blochwitz
Reported by andreas.junghanns on 4 Jan 2013 16:14 UTC
Currently, the callbacks specified for memory management are allocate and free.
If FMU code uses realloc() then this cannot be faked by malloc-memcpy-free because the previous size of the memory is missing for the memcpy action.
Suggestion: Replace allocateMemory with reallocateMemory and accept a first argument that can be NULL.
[email protected] requested such a function as well in his email from Feb 16, 2012.
Migrated-From: https://trac.fmi-standard.org/ticket/122
The text was updated successfully, but these errors were encountered: