Send data directly to Google Spreadsheet doesn't work properly

Hi
I am trying to make this example to work: https://mongoose-os.com/docs/mongoose-os/howtos/trix.md
It was suspicious to me that logs doesn’t come at specified intervals, so I modified example to log simple counter:

    #include "mgos.h"

const char *s_url = "https://script.google.com/macros/s/AKfycbw4aaRW5x-oHimo-kOw29SDOHa
qhFUEgb1zT_wHtq3jcyAXa/exec";
static int counter1 = 0;

static void timer_cb(void *arg) {
  char buf[100];
  struct json_out out = JSON_OUT_BUF(buf, sizeof(buf));
  json_printf(&out, "[%d]", counter1);
  LOG(LL_INFO, ("counter1: %d", counter1)); // log to console to compare with what logged to Google Spreadsheep
  mg_connect_http(mgos_get_mgr(), NULL, NULL, s_url, NULL, buf);
  counter1++ ;
  (void) arg;
}

enum mgos_app_init_result mgos_app_init(void) {
  mgos_set_timer(10000, MGOS_TIMER_REPEAT, timer_cb, NULL);
  return MGOS_APP_INIT_SUCCESS;
}

And indeed there some records missed in Google Spreadsheet:
Here is what I get in Spreadsheet:
|19/09/2019 23:20:50|0|
|19/09/2019 23:21:11|2|
|19/09/2019 23:21:22|3|
|19/09/2019 23:21:31|4|
|19/09/2019 23:21:42|5|
|19/09/2019 23:21:53|6|
|19/09/2019 23:22:10|7|
|19/09/2019 23:25:32|28|
|19/09/2019 23:25:42|29|
|19/09/2019 23:25:52|30|
|19/09/2019 23:26:03|31|
|19/09/2019 23:26:23|33|
|19/09/2019 23:26:49|35|
|19/09/2019 23:27:30|39|

My connection is rock solid, this can’t be an issue.
Any thoughts?

Log to console shows that counter1 is properly incrementing.
The chip is ESP8266, 4mb flash, NodeMCU

Here is overnight log:

Start from zero means that ESP8266 reboot itself.
It looks like post to Google Spreadsheet doesn’t have any mechanism to prevent missed jammed packets?

Observe the free RAM too.
I suspect that the HTTPS connections sometimes get piled up, and since they are fat, the ESP just gets OOM .

ESP8266 has a hard time to process the https connections:

timestamp from script	timestamp from esp	min_free_heap	count	platform																					
20/09/2019 11:32:05	2019-09-20 11:31:55	41328	0	esp8266																					
20/09/2019 11:32:35	2019-09-20 11:32:25	30000	1	esp8266																					
20/09/2019 11:33:05	2019-09-20 11:32:55	30000	2	esp8266																					
20/09/2019 11:33:37	2019-09-20 11:33:25	30000	3	esp8266																					
20/09/2019 11:34:06	2019-09-20 11:33:55	30000	4	esp8266																					
20/09/2019 11:34:37	2019-09-20 11:34:25	30000	5	esp8266																					
20/09/2019 11:35:06	2019-09-20 11:34:55	30000	6	esp8266																					
20/09/2019 11:35:35	2019-09-20 11:35:25	30000	7	esp8266																					
20/09/2019 11:36:05	2019-09-20 11:35:55	30000	8	esp8266																					
20/09/2019 11:36:35	2019-09-20 11:36:25	30000	9	esp8266																					
20/09/2019 11:37:05	2019-09-20 11:36:55	29920	10	esp8266																					
20/09/2019 11:37:36	2019-09-20 11:37:25	29920	11	esp8266																					
20/09/2019 11:38:16	2019-09-20 11:37:55	29920	12	esp8266																					
20/09/2019 11:38:35	2019-09-20 11:38:25	29920	13	esp8266																					
20/09/2019 11:39:46	2019-09-20 11:39:44	213780	0	esp32																					
20/09/2019 11:39:57	2019-09-20 11:39:54	212324	1	esp32																					
20/09/2019 11:40:06	2019-09-20 11:40:04	211748	2	esp32																					
20/09/2019 11:40:16	2019-09-20 11:40:14	211748	3	esp32																					
20/09/2019 11:40:27	2019-09-20 11:40:24	209864	4	esp32																					
20/09/2019 11:40:36	2019-09-20 11:40:34	209864	5	esp32																					
20/09/2019 11:40:46	2019-09-20 11:40:44	209864	6	esp32																					
20/09/2019 11:40:56	2019-09-20 11:40:54	209864	7	esp32																					
20/09/2019 11:41:06	2019-09-20 11:41:04	209864	8	esp32																					
20/09/2019 11:41:16	2019-09-20 11:41:14	209864	9	esp32																					
20/09/2019 11:41:26	2019-09-20 11:41:24	209836	10	esp32																					
20/09/2019 11:41:36	2019-09-20 11:41:34	209836	11	esp32																					
20/09/2019 11:41:46	2019-09-20 11:41:44	209836	12	esp32																					
20/09/2019 11:41:56	2019-09-20 11:41:54	209648	13	esp32																	

Okay, the problem is that ESP8266 is out of RAM after 7-8 records sent. It looks like the exampe is RAM hungry.

ESP32 works stable. The example needs at least 60 kb of free RAM to work.
But ESP32 but still loses about one on 200 jsons sent to Google Spreadsheet. Is there a solution for this problem? Should I use MQTT to eliminate data loss?

Also can you give an example how to write two values in 2 separate cells on each row?
I have tried this: json_printf(&out, “[%d], [%d]”, counter1, counter2);
but it doesn’tn work.

I have found how to post 2 values.
json_printf(&out, “[%d, %d]”, counter1, counter2);