Created
August 15, 2019 01:04
-
-
Save jsign/6df2de9eb6ef7534744d4f95692fa771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"runtime" | |
"runtime/pprof" | |
"strings" | |
"github.com/prologic/bitcask" | |
) | |
func main() { | |
s, err := bitcask.Open("hello.db") | |
if err != nil { | |
log.Fatalf("error while opening the database: %v", err) | |
} | |
totalVolumeSize := 800 << 20 | |
valueSize := 4 << 10 | |
value := []byte(strings.Repeat(" ", valueSize)) | |
for i := 1; i <= totalVolumeSize/valueSize; i++ { | |
key := fmt.Sprintf("%32v", i) | |
s.Put([]byte(key), value) | |
} | |
f, err := os.Create("heap.out") | |
if err != nil { | |
log.Fatal("memory profile file: ", err) | |
} | |
defer f.Close() | |
runtime.GC() | |
pprof.WriteHeapProfile(f) | |
s.Close() | |
os.RemoveAll("hello.db") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment