[Ovmsdev] Memory leak

Stephen Casner casner at acm.org
Wed Apr 25 13:20:17 HKT 2018


Mark,

OK, I'll change mongoose to explicitly allocate from SPIRAM when
available.  I won't be able to completely test it, though, since I
only have v3.0.

                                                        -- Steve

On Wed, 25 Apr 2018, Mark Webb-Johnson wrote:

> Steve,
>
> Because of things like this:
>
> https://github.com/espressif/esp-idf/issues/1492 <https://github.com/espressif/esp-idf/issues/1492>
>
> I tried setting the "SPI RAM access method" to "Make RAM allocatable using malloc() as well", and reducing "Maximum malloc() size, in bytes, to always put in internal memory" to 32 bytes, but get this crash on startup…
>
> Presumably that is esp_event_loop_init trying to create a FreeRTOS queue, and then objecting because it is not in internal RAM? It seems that the ESP IDF framework is not fully working with SPI RAM yet (due to inherent limitations). It would be better if the memory to be allocated must be internal, it is specifically allocated as internal (rather than just rely on a generic malloc).
>
> Last time I tried it (earlier this year), the ESP-IDF just simply didn’t work when that menuconfig option was set. When I fixed the above specific bug, it happened in another place.
>
> I know Espressif have been working on it, and perhaps they’ve fixed it now? This commit seems to try to address it in a generic way (at least for the freertos port stuff, if not for all the other libraries that we use):
>
> https://github.com/espressif/esp-idf/commit/16de6bff245dec5e63eee994f53a08252be720d4 <https://github.com/espressif/esp-idf/commit/16de6bff245dec5e63eee994f53a08252be720d4>
>
> IDF 3.0 has officially been released last night.
>
> Regards, Mark.
>
> > On 25 Apr 2018, at 4:40 AM, Stephen Casner <casner at acm.org> wrote:
> >
> > We've been dancing around the external RAM allocation decision with
> > our own ExtenalRamMalloc() function and extensions to the C++ new
> > allocator to try SPIRAM first but then back off to internal memory if
> > that fails (presumably because of v3.0 hardware rather than because
> > all 4MB of SPIRAM is used up).
> >
> > Do we need all that?  There is already a mechanism in the multi-heap
> > memory system for the defaut malloc to try allocating from SPIRAM for
> > any request with size larger than malloc_alwaysinternal_limit which
> > can be set dynamically with heap_caps_malloc_extmem_enable().  If the
> > allocation from SPIRAM fails (again, presumably only on v3.0 hardware)
> > then the allocation is retried without the MALLOC_CAP_SPIRAM
> > capability, which is just what our ExternalRamMalloc does.
> >
> > If there are only a few allocations such as stacks that must come from
> > internal memory, and if those allocations (in system code) already use
> > heap_caps_malloc(MALLOC_CAP_INTERNAL) to meet that requirement, then
> > we could probably just set malloc_alwaysinternal_limit to a small
> > number (perhaps 0) so that everything else comes from SPIRAM.
> >
> > I don't know if any of our application memory uses are sufficiently
> > sensitive to memory performance that we would want to ensure that the
> > memory is internal.  My guess is that those would be few and therefore
> > it makes sense to take special action for them rather than for
> > everything else.
> >
> > For continued support of v3.0 hardware we could even test whether
> > SPIRAM is present and leave malloc_alwaysinternal_limit at its default
> > value of -1 if not.
> >
> > Opinions?
> >
> >                                                        -- Steve
> >
> > On Mon, 23 Apr 2018, Mark Webb-Johnson wrote:
> >
> >> Michael,
> >>
> >> Do we need ovms_extram.h? Can we just put the namespace directly
> >> into ovms.h (where all the other external ram allocation stuff is)?
> >>
> >> Regards, Mark
> > _______________________________________________
> > OvmsDev mailing list
> > OvmsDev at lists.openvehicles.com
> > http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>
>


More information about the OvmsDev mailing list