Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. DLMS IGNORE MALLOC

DLMS IGNORE MALLOC

By Pablob, 24 September, 2025
Forums
Gurux DLMS for ANSI C

Hello,

I’ve successfully developed a DLMS host in C using the Gurux ANSI C library. It runs on a microcontroller with limited resources.

In the provided examples, the library uses dynamic memory (malloc()/free()). As you probably know, is not ideal on a microcontroller because memory fragmentation can happen.

To make the host more robust, I uncommented #DLMS_IGNORE_MALLOC in gxignore.h.
My problem is that I still need several functions declared in client.h, and those prototypes are only available when DLMS_IGNORE_MALLOC is not defined.

My question is, is it possible to implement a host without using malloc() and free()?
If so, is there anay example available?

Thanks

Pablo

Profile picture for user Kurumi

Kurumi

2 months 1 week ago

Hi Pablo, If you need to…

Hi Pablo,

If you need to implement the client-side, you need malloc.

The reason is that the client is unaware of the type of data the meter is returning, and it needs to allocate the memory after the data is read from the meter.

The meter side can be implemented without malloc, because the meter defines what data it wants to offer and in what format.

BR,
Mikko

Pablob

2 months 1 week ago

Hello Kurumi, thank you so…

Hello Kurumi, thank you so much for your answer.

Is it possible to create variables with a fixed size so that, if the data received is larger than the available space, an error is returned?

Would it be possible to modify the client.h functions to work this way, or is that too messy and not recommended?

Could we get support with these modifications?

Thanks!

Pablo

Profile picture for user Kurumi

Kurumi

2 months 1 week ago

Hi Pablo, The meter can…

Hi Pablo,

The meter can return any kind of data. If you want to implement a gateway, etc, where the client reads data from the meter and then sends the received data to the HES, you don't need to parse data. You can just send it to the HES without parsing.

You can ignore the cl_updateValue and send the received bytes.

Parsing data might take a lot of memory, and if you want to parse the data on an MCU, it must be done in parts.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 12/02/2025 - 10:21
    gurux.dlms.c 9.0.2512.0201
  • Mon, 12/01/2025 - 13:55
    Gurux.DLMS.Python 1.0.193
  • Thu, 11/13/2025 - 15:23
    Gurux.DLMS.Python 1.0.192
  • Thu, 11/13/2025 - 14:55
    gurux.dlms.java 4.0.84
  • Wed, 10/29/2025 - 08:51
    gurux.dlms.c 9.0.2510.2901

New forum topics

  • Incomplete Firmware Upgrade Process
  • SNRM byte mening
  • P384 Client Certificate incorrect issuer CN
  • Confirmed push service support
  • DLMS Stack hang during Firmware Upgrade
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin