Skip to content

Fix fileBuffer RAM allocation #20

Closed
@adamgarbo

Description

@adamgarbo
Contributor

Hi @PaulZC,

As discussed earlier, we'll need to fix how the .createFileBuffer() function allocates RAM. At present, if the system makes multiple calls to .begin(), RAM usage will eventually exceed the available memory (e.g. a 16 KB file buffer will consume all 384 KB RAM on the Artemis after 24 sleep/wake cycles). In actuality, this seems to occur at about the 14th sleep/wake cycle, which causes an immediate hard reset of the processor.

Offending line of code:

ubxFileBuffer = new uint8_t[fileBufferSize]; // Allocate RAM for the buffer

Cheers,
Adam

Activity

added a commit that references this issue on Apr 1, 2021

Correct #20. Add .end. Add getFileBufferSize. Add Example26

PaulZC

PaulZC commented on Apr 1, 2021

@PaulZC
Collaborator

Thanks for finding this Adam!
Corrected in this commit.
Please give Example26 a try.

adamgarbo

adamgarbo commented on Apr 1, 2021

@adamgarbo
ContributorAuthor

Thanks, Paul!

Will try it out this morning. Can you clarify what you mean by "End will stop all automatic message processing and free (nearly) all used RAM."? Is there still some RAM that will be lost after each .begin() call? Thinking about long-term (1-year) deployments of the code.

Cheers,
Adam

PaulZC

PaulZC commented on Apr 1, 2021

@PaulZC
Collaborator

Hi Adam,
The memory leak - from multiple calls to .begin - should be completely fixed.
.end is optional but you can use it to deallocate (delete) all of the allocated RAM except payloadCfg. (That's why I use the word "nearly"!).
Cheers,
Paul

adamgarbo

adamgarbo commented on Apr 1, 2021

@adamgarbo
ContributorAuthor

Thanks, Paul!

I've been letting the code run all morning and am currently up to 40 sleep/wake cycles with a 16 KB buffer and no issues!

Cheers,
Adam

PaulZC

PaulZC commented on Apr 1, 2021

@PaulZC
Collaborator

Jolly good!
Have a nice Easter!
:-)

linked a pull request that will close this issuev2.0.5 #21on Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @PaulZC@adamgarbo

      Issue actions

        Fix fileBuffer RAM allocation · Issue #20 · sparkfun/SparkFun_u-blox_GNSS_Arduino_Library