Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1358
Closed
Open
Issue created Aug 25, 2020 by Administrator@rootContributor

Dynamic memory management: silently doing nothing is a real problem when robustness is needed

Created by: richnwhit

I'm using this excellent library in an industrial product. It has to work solidly, reliably, 100% of the time, and unfortunately I'm not getting that, due to memory problems.

Working out exactly how much memory is required is very tricky (and would be a maintenance nightmare – I wouldn’t expect someone coming along adding a new field to remember to add it to the memory capacity), and I’m working in a tiny chip so I can’t just give it loads. So I tend to measure how much it needs in a typical situation using memoryUsage, double it, and use that amount.

But I keep having problems that I can’t reproduce. It works fine in all my unit tests, and in the PC-based library, but when I run it on my target microcontroller, often the JSON will be incomplete, which I suspect is because it’s run out of memory. Sometimes there are empty objects (“{}”), and sometimes I get very long lines and my parser bombs out after 1000 characters without a linefeed.

Ideal solutions would be:

  1. A memory allocator that allocates memory from the heap as it's needed, rather than all at the start.
  2. In the existing scheme, the ability to throw an exception or at least print a warning when it runs out of memory rather than silently doing nothing. I can't think why anyone would want it to just silently do nothing!

As a bare minimum, please could someone point out where in the code it checks if it has enough memory, so I could add some code in my project?

Assignee
Assign to
Time tracking