i'm having trouble using SSL because espconn_secure_connect requires so much RAM.

here is a simple application, that does the bare minimum necessary to fetch https://www.google.com

it has a 10ms timer that prints output of system_get_free_heap_size, and here's what it looks like:

heap free: 41376

wifi event: 3, heap free: 41288<--- wifi status change callback, parses URL and invokes espconn_gethostbyname

resolving... (hf 38616)<--- immediately before espconn_gethostbyname

ip:192.168.1.84,mask:255.255.255.0,gw:192.168.1.1

heap free: 38520

heap free: 38704

heap free: 38704

heap free: 38704

heap free: 38704

heap free: 38704

heap free: 38704

heap free: 38704

connecting (secure=1, port=443, hf=38664)...<-- immediately before espconn_secure_connect

heap free: 38192

heap free: 38192

heap free: 38192

heap free: 38192

heap free: 38192

heap free: 38192

heap free: 38192

heap free: 38192

heap free: 29000<--- !!! -10K in one go

heap free: 29000

heap free: 29000

heap free: 29000

client handshake start.

heap free: 30632

heap free: 30632

heap free: 30632

heap free: 30632

heap free: 30632

heap free: 30632

heap free: 30632

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 30528

heap free: 18616<--- !!!!!!!!! yum, another 12K, thank you very much

heap free: 18616

heap free: 18616

heap free: 18616

heap free: 18616

heap free: 18616

client handshake ok!<-- printed by SDK

sending request... hf=29784<-- printed from the connect callback (registered with espconn_regist_connectcb)

heap free: 29824note that 10k is still allocated, while we're awaiting response, maybe for buffers or something. kinda high if you ask me.

heap free: 29824

heap free: 29824

...

so, as you can see, at its peak, the amount of memory needed just for SSL handshake is almost 20K (38 - 18).

this is nowhere near the value set by espconn_secure_set_size, which is 4096 in my case.

i think this sort of memory usage is unreasonable. there's waste there somewhere...

and, for comparison, here's the same request to http://www.google.com - everything else the same, just removed "s" (which invokes espconn_connect now instead of secure_connect, obviously).

heap free: 41376

wifi event: 3, heap free: 41288

resolving... (hf 38616)

ip:192.168.1.84,mask:255.255.255.0,gw:192.168.1.1

heap free: 38400

heap free: 38704

heap free: 38704

heap free: 38704

connecting (secure=0, port=80, hf=38664)...

heap free: 38192

heap free: 38192

heap free: 38192

sending request... hf=38288

heap free: 36696

heap free: 36696

heap free: 36696

heap free: 36696

heap free: 38368

heap free: 38368

heap free: 38368

recv resp 1095...

response: HTTP/1.0 302 Found

Location: http://www.google.ie/?gws_rd=cr&ei=mva4 ... 7ga0z774CQ

...more headers from google.com here...

heap free: 41344