fix memory leak
This commit is contained in:
parent
320d61551b
commit
c84421a2ad
2 changed files with 15 additions and 4 deletions
|
@ -9,8 +9,8 @@
|
|||
#include "utils.h"
|
||||
#include "error.h"
|
||||
|
||||
bus *b = new bus();
|
||||
cpu *c = new cpu(b);
|
||||
bus *b = nullptr;
|
||||
cpu *c = nullptr;
|
||||
tty *tty_ = nullptr;
|
||||
|
||||
uint16_t loadbin(bus *const b)
|
||||
|
@ -222,6 +222,12 @@ void setup() {
|
|||
Serial.print(F("Size of int: "));
|
||||
Serial.println(sizeof(int));
|
||||
|
||||
Serial.print(F("CPU clock frequency: "));
|
||||
Serial.println(getCpuFrequencyMhz());
|
||||
|
||||
Serial.print(F("Free RAM before init: "));
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
|
||||
Serial.println(F("Init bus"));
|
||||
b = new bus();
|
||||
|
||||
|
@ -242,6 +248,9 @@ void setup() {
|
|||
exec_addr = loadbin(b);
|
||||
c->setRegister(7, exec_addr);
|
||||
|
||||
Serial.print(F("Free RAM after init: "));
|
||||
Serial.println(ESP.getFreeHeap());
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.println(F("Press <enter> to start"));
|
||||
|
@ -280,7 +289,7 @@ void loop() {
|
|||
Serial.println(F(" *** EMULATION STOPPED *** "));
|
||||
Serial.print(F("Instructions per second: "));
|
||||
Serial.println(icount * 1000.0 / (millis() - start_ts));
|
||||
delay(1000);
|
||||
delay(3000);
|
||||
Serial.println(F(" *** EMULATION RESTARTING *** "));
|
||||
|
||||
c->setRegister(7, exec_addr);
|
||||
|
|
4
bus.cpp
4
bus.cpp
|
@ -16,7 +16,9 @@
|
|||
bus::bus() : c(nullptr), tm11(nullptr), rk05_(nullptr), rx02_(nullptr), tty_(nullptr)
|
||||
{
|
||||
#if defined(ESP32)
|
||||
int n = 8;
|
||||
// ESP32 goes in a crash-loop when allocating 128kB
|
||||
// see also https://github.com/espressif/esp-idf/issues/1934
|
||||
int n = 14;
|
||||
#else
|
||||
int n = 16;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue