Micro Arcade Reverse Engineering

In which case the only way to track down the leak is probably going to be to read the source code of HTTPClient.

How are you measuring the heap/RAM usage of the program?
What is your strimmed down example like?

I think I’ve found the source, but it’s worth mentioning that it actually uses String internally so a bug in String can’t be ruled out either. (Yay(!))

The object’s destructor is called, but whether or not that cleans up all the resources that the object has allocated depends on whether the author has implemented the destructor properly.

E.g. if you wrote a class like so:

class Wasteful
  char * memory;

  Wasteful() :
    // Allocate 1KB
    memory { new char[1024] }

    // Oops, forgot to deallocate

You’d be leaking memory all over the place.

That’s one of the reasons using smart pointers is encouraged:

class Safe
  std::unique_ptr<char []> memory;

  Safe() :
    memory { std::make_unique<char []>(1024) }

  // No need to make a destructor,
  // the default destructor provided by the compiler will call
  // std::unique_ptr<char []>::~unique_ptr()
  // which will handle all the cleanup for you.

Ideally in modern C++ code you should very rarely be touching raw pointers at all,
and you should almost never have to use new or delete.

Are you calling it before begin and end?

If you’ve got the message logging enabled you ought to at least get either:

“[HTTP-Client][end] tcp keep open for reuse\n”


“[HTTP-Client][end] tcp stop\n”

Also, try using setURL instead of end before calling end.
Might not fix the memory leak, but it might fix the other issue.

Ok, that’s what I thought, so “theoretically” in a perfect world declaring it within the scope of each functions should clean it up, but if the destructor isn’t correct or there is some underlying memory problem in the code it will still be the problem.

I’ll dig deeper into the code and see, I think the correct implementation is to keep just one http object but just need to successfully point it at different places.

I think it was the json listener class that was leaking, i’m puitting it within scope of the functions to see if destructing it helps.

Moving all the json parsing initializations into the scope of the functions seems to have solved the problem so I’m not going to worry about it too much! :smiley:

It seems to have crashed for no reason, I kind of suspect the wifi might just randomly take a shit?

This isn’t using an official module, maybe the voltage regulator is just browning out when the wifi spikes?

Seems power related, with a large capacity battery and plugged in to USB it hasn’t crashed once.

I’ve read doing wifi stuff can pull as much as 2amps instantaneously so this would make sense because the smaller micro-arcade battery can barely output that and neither can usb by itself.

2 amps is a lot! I wonder how anyone using HTTP and a battery are making it work?

The battery I’m using now is 1800 mAh so it can easily produce about 3A

Yep … try squeezing that back into the Micro Arcade housing!

It works on the Micro Arcade battery just not totally all the time. Probably will be ok if I can put a large value capacitor on there. The power draw is only for a couple milliseconds.

Got the ESP IDF extension running, compiling and flashing to the ESP32, but I can’t figure out how to bring in the doom project and get it to include all of the files in the components directory. Probably has to do with project settings or pointing it at the include directory but I don’t have a clue to how to use visual studio in so many years so after about an hour of trying I put it on hold.

Anyone know how to setup include directories in visual studio code? I tried doing google searches for this and really didn’t get very far.

It seems the code is intended to be compiled on a linux system or something with a make command, the windows toolchain seems to be using cmake which I think is part of the struggle?

UPDATE: Figured out how to get them to be included but now I’m dealing with a ton of errors having to do with stuff that should otherwise be warnings that whatever compiler this is built on doesn’t care about like having if clauses not guarding with {} properly.

Not sure if I could get it up with platformio instead or maybe I need to find a laptop to run linux on.

Still at it. This time with an RP2040


I’m pretty excited about this, I wish I had more Micro Arcades laying around lol.