Skip to content

Instantly share code, notes, and snippets.

@flebel
Last active May 2, 2017 00:09
Show Gist options
  • Save flebel/d0a16fc3af2b63b4730b1da5a8b947fa to your computer and use it in GitHub Desktop.
Save flebel/d0a16fc3af2b63b4730b1da5a8b947fa to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func doEvery(d time.Duration, f func(time.Time)) {
for x := range time.Tick(d) {
SmallSlab = append(SmallSlab, make([]byte, 1024*1024)...)
f(x)
}
}
func printTime(t time.Time) {
fmt.Printf("%v\n", t)
}
// Slab of allocated memory
var Slab []byte
var SmallSlab []byte
func main() {
Slab = make([]byte, 1024*1024*1024*5) // 5GB
SmallSlab = make([]byte, 1024)
doEvery(500*time.Millisecond, printTime)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment