lundi 20 février 2017

How can i limit/gate memory usage in go unit test

Is there a way to limit the amount of memory usage/growth during a unit test in golang?

For example, in java, we can do:

long before = Runtime.getRuntime().freeMemory()

// allocate a bunch of memory
long after = Runtime.getRuntime().freeMemory()

Assert.AssertTrue(before-after < 100)

(roughly) to assert that we didn't use more than 100 bytes.

Aucun commentaire:

Enregistrer un commentaire