u/xobodox - 2 Archived Voat Posts in v/programming
u/xobodox
  • home
  • search

u/xobodox

1 post · 1 comment · 2 total

Active in: v/programming (2)

  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››
Comment on: JavaScript String Incrementer

Looks like this could be used to check for memory leaks in NodeJS.. LOL!

<--- Last few GCs --->
  404429 ms: Scavenge 1398.5 (1457.3) -> 1398.5 (1457.3) MB, 1.4 / 0 ms (+ 3.0 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
  405718 ms: Mark-sweep 1398.5 (1457.3) -> 1398.5 (1457.3) MB, 1289.0 / 0 ms (+ 4.0 ms in 2 steps since start of marking, biggest step 3.0 ms) [last resort gc].
  407048 ms: Mark-sweep 1398.5 (1457.3) -> 1398.5 (1457.3) MB, 1329.2 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000000F4D00B4639 <JS Object>
    1: nextTick [node.js:~478] [pc=000003EF61D88171] (this=0000016262607271 <a process with map 0000026F3EB10D31>,callback=00000356E8BE2381 <JS Function afterWrite (SharedFunctionInfo 00000356E8B2B521)>)
    2: arguments adaptor frame: 5->1
    3: onwrite(aka onwrite) [_stream_writable.js:~322] [pc=000003EF61D759FC] (this=000000F4D00041B9 <undefined>,stream=00000356E8BE0169 <a WriteStream wit...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

Also, if you want to check performance between NodeJS and C..

#include <stdio.h>
#include <string.h>
void chars_increment(char* arr, char min, char max)
{
    ssize_t last = strlen(arr)-1;
    if (last < 0) {
        arr[0] = min;
        return;
    }
    while(arr[last] >= max) {
        arr[last--] = min;
        if (last < 0) break;
    }
    if (last < 0) {
        arr[strlen(arr)] = min; //potentially unsafe
    } else {
        arr[last]++;
    }
}
int main(int argc, char* argv[])
{
    char buf[80];
    memset(buf, 0x0, sizeof(buf));
    while (strlen(buf) < 6) {
        chars_increment(buf, 65, 90);
        printf("buf = [%s]\n", buf);
    }
    return 0;
}
0 29 Jan 2017 03:08 u/xobodox in v/programming
JavaScript String Incrementer
4 1 comment 28 Jan 2017 20:56 u/xobodox (self.programming) in v/programming
  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››

archive has 9,592 posts and 65,719 comments. source code.