Skip to content

Fix localtime/1 mem leak#2083

Draft
petermm wants to merge 1 commit intoatomvm:mainfrom
petermm:fix-localtime-leak
Draft

Fix localtime/1 mem leak#2083
petermm wants to merge 1 commit intoatomvm:mainfrom
petermm:fix-localtime-leak

Conversation

@petermm
Copy link
Contributor

@petermm petermm commented Feb 3, 2026

Fixes #2062

replicate:

  def myloop do
    :erlang.localtime("CET-1CEST,M3.5.0,M10.5.0/3")
    |> IO.inspect()

    :timer.sleep(100)

    :erlang.system_info(:esp32_free_heap_size)
    |> IO.inspect()

    myloop()
  end

And see rapidly decreasing free memory - solution inspired by espressif/esp-idf#9764

Currently in draft, as I believe there is some issue with setting the tz to "" on generic_unix - which means it is set to utc, just need to understand that or guard it..

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

espressif/esp-idf#9764

Signed-off-by: Peter M <petermm@gmail.com>
@petermm petermm force-pushed the fix-localtime-leak branch from e336026 to 3683b3a Compare February 3, 2026 20:47
@bettio
Copy link
Collaborator

bettio commented Feb 6, 2026

This is a non trivial issue and I'm investigating a fix as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leak in erlang:localtime/1

2 participants