Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.concurrent.ConcurrentHashMap;
- import java.util.stream.IntStream;
- public class Survey {
- public static void main(String[] args) {
- ConcurrentHashMap<String, List<ConcurrentHashMap<String, Object>>> testMap = new ConcurrentHashMap<>();
- long start = 0;
- long end = 0;
- // 先垃圾回收
- System.gc();
- start = Runtime.getRuntime().freeMemory();
- IntStream.range(0, 4000).forEach(i -> {
- String topic = "market.eosusdt.kline.1min" + i;
- ConcurrentHashMap<String, Object> data = new ConcurrentHashMap<>();
- data.put("id", 1537325760);
- data.put("open", 5.1214);
- data.put("close", 5.1199);
- data.put("low", 5.117);
- data.put("high", 5.1223);
- data.put("amount", 1947.6461);
- data.put("vol", 9972.01690388);
- data.put("count", 18);
- List<ConcurrentHashMap<String, Object>> datas = new ArrayList<>();
- IntStream.range(0, 2000).forEach(j -> datas.add(data));
- testMap.put(topic, datas);
- });
- // 快要计算的时,再清理一次
- System.gc();
- end = Runtime.getRuntime().freeMemory();
- System.out.println("占内存:" + (end - start) / 1000.0 + "M");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement