You are reading a single comment by @tve and its replies. Click here to read the full conversation.
  • Here's the debug output:

    >jswrap_net_connect
    clientRequestNew
    1
    Alloc 71
    Alloc 141
    Alloc 151
    Alloc 153
    Free 359
    Free 360
    2
    Alloc 359
    Alloc 360
    Alloc 362
    Alloc 273
    Free 373    <=============
    Free 374
    3
    Alloc 373
    Alloc 374
    Free 373
    4
    Alloc 373
    Alloc 376
    Alloc 274
    5
    Alloc 275
    Alloc 276
    6
    Alloc 308
    x clientRequestNew
    

    So #373 gets freed in clientRequestNew and the "1", "2", ... markers are from printf's that divide up the function:

    JsVar *clientRequestNew(SocketType socketType, JsVar *options, JsVar *callback) {
      printf("clientRequestNew\n");
      JsVar *arr = socketGetArray(HTTP_ARRAY_HTTP_CLIENT_CO­NNECTIONS,true);
      if (!arr) return 0;
      JsVar *req, *res = 0;
      printf("1\n");
      if ((socketType&ST_TYPE_MASK)==ST_HTTP) {
        res = jspNewObject(0, "httpCRs");
      printf("2\n");
        if (!res) { jsvUnLock(arr); return 0; } // out of memory?
        req = jspNewObject(0, "httpCRq");
      } else {
        req = jspNewObject(0, "Socket");
      }
      printf("3\n");
      if (req) { // out of memory?
       socketSetType(req, socketType);
      printf("4\n");
       if (callback != NULL)
         jsvUnLock(jsvAddNamedChild(req, callback, HTTP_NAME_ON_CONNECT));
    
      printf("5\n");
       jsvArrayPush(arr, req);
       if (res)
         jsvObjectSetChild(req, HTTP_NAME_RESPONSE_VAR, res);
      printf("6\n");
       jsvObjectSetChild(req, HTTP_NAME_OPTIONS_VAR, options);
      }
      jsvUnLock2(res, arr);
      printf("x clientRequestNew\n");
      return req;
    }
    

    So the proto somehow gets freed in jspNewObject(0, "httpCRq"); on the 255-th request... Mhhh, is the reference or lock count perhaps a byte and only allows 255 references/locks? Does this mean the problem is that the httpCRq object that gets created for each request doesn't get freed or unlocked somewhere?

About

Avatar for tve @tve started