<commit_before>const TestType1 = require('./test/DotNetTest-TestType1.js');
const TestType2 = require('./test/DotNetTest-TestType2.js');
const edge = require('edge');
const assert = require('assert');
const process = require('process');

var ReferenceCount = edge.func({ source: () => {/*
  #r "./dotnet/bin/Debug/EdgeReference.dll"

  using System.Threading.Tasks;

  public class Startup {
    public async Task<object> Invoke(object input) {
      return EdgeReference.ReferenceManager.Instance.Count;
    }
  }
*/}});


var beforeCount = ReferenceCount(null, true);
var i = 0;
var parent = {};

while (++i < 1000) {
  parent.tt1 = new TestType1();
  var afterCount = ReferenceCount(null, true);

  assert.ok(afterCount);
  assert.notEqual(afterCount, beforeCount);

  delete parent.tt1;
}

setTimeout(() => {
  global.gc();
  var lastCount = ReferenceCount(null, true);
  console.log(lastCount);
  console.log(beforeCount);
  console.log(afterCount);
  assert.ok(lastCount <= beforeCount);
  done();
}, 1000);
<commit_msg>Working garbage collection and associated test.<commit_after>const TestType1 = require('./test/DotNetTest-TestType1.js');
const TestType2 = require('./test/DotNetTest-TestType2.js');
const edge = require('edge');
const assert = require('assert');
const process = require('process');

var ReferenceCount = edge.func({ source: () => {/*
  #r "./dotnet/bin/Debug/EdgeReference.dll"

  using System.Threading.Tasks;

  public class Startup {
    public async Task<object> Invoke(object input) {
      return EdgeReference.ReferenceManager.Instance.Count;
    }
  }
*/}});


var beforeCount = ReferenceCount(null, true);
var i = 0;
var parent = {};

while (++i < 1000) {
  parent.tt1 = new TestType1();
  var afterCount = ReferenceCount(null, true);

  assert.ok(afterCount);
  assert.notEqual(afterCount, beforeCount);

  delete parent.tt1;
}

global.gc();

setTimeout(() => {
  var lastCount = ReferenceCount(null, true);
  console.log(lastCount);
  console.log(beforeCount);
  console.log(afterCount);
  assert.ok(lastCount <= beforeCount);
}, 1000);

{'fraction_non_alphanumeric': 0.15710843373493977, 'fraction_numerical': 0.015421686746987951, 'mean_word_length': 4.536, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3564187', 'n_tokens_mistral': 679, 'n_tokens_neox': 649, 'n_words': 144}