<commit_before>var Easy = require('../lib/Easy'),
  readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

var instances = [],
  amount = 1e3,
  iteration = 0,
  handle;

var postData = [
  {
    name: 'file',
    file: 'test.img',
    type: 'image/png',
  },
];

function createOrCloseCurlHandles() {
  var i = amount,
    shouldClose = iteration++ % 2;

  if (shouldClose) {
    console.log('Closing handles.');
  } else {
    console.log('Opening handles.');
  }

  while (i--) {
    if (shouldClose) {
      instances[i].close();
      instances[i] = null;
    } else {
      handle = new Easy();
      handle.setOpt('HTTPPOST', postData);
      instances[i] = handle;
    }
  }

  if (global.gc && shouldClose) {
    console.log('Calling garbage collector.');
    global.gc();
  }

  handle = null;
}<commit_msg>refactor: add a callback to brute force leak test<commit_after>var Easy = require('../lib/Easy'),
  Curl = require('../lib/Curl'),
  readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

var instances = [],
  amount = 1e3,
  iteration = 0,
  handle;

var postData = [
  {
    name: 'file',
    file: 'test.img',
    type: 'image/png',
  },
];

function createOrCloseCurlHandles() {
  var i = amount,
    shouldClose = iteration++ % 2;

  if (shouldClose) {
    console.log('Closing handles.');
  } else {
    console.log('Opening handles.');
  }

  while (i--) {
    if (shouldClose) {
      instances[i].close();
      instances[i] = null;
    } else {
      handle = new Easy();
      handle.setOpt('HTTPPOST', postData);
      handle.setOpt(Curl.option.XFERINFOFUNCTION, () => {});
      instances[i] = handle;
    }
  }

  if (global.gc && shouldClose) {
    console.log('Calling garbage collector.');
    global.gc();
  }

  handle = null;
}
{'fraction_non_alphanumeric': 0.17034700315457413, 'fraction_numerical': 0.004206098843322818, 'mean_word_length': 2.768316831683168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '947203', 'n_tokens_mistral': 664, 'n_tokens_neox': 663, 'n_words': 143}