| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 
 | self()的数据  模拟玩家进程1> erlang:process_info(self(), [garbage_collection_info,garbage_collection,memory])
 [{garbage_collection_info,[{old_heap_block_size,0},
 {heap_block_size,987},
 {mbuf_size,90},
 {recent_size,460},
 {stack_size,26},
 {old_heap_size,0},
 {heap_size,935},
 {bin_vheap_size,4},
 {bin_vheap_block_size,46422},
 {bin_old_vheap_size,0},
 {bin_old_vheap_block_size,46422}]},
 {garbage_collection,[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
 {min_bin_vheap_size,46422},
 {min_heap_size,233},
 {fullsweep_after,65535},
 {minor_gcs,0}]},
 {memory,8720}]
 
 Pid 模拟大富翁进程
 erlang:process_info(Pid, [garbage_collection_info,garbage_collection,memory]).
 
 [{garbage_collection_info,[{old_heap_block_size,0},
 {heap_block_size,233},
 {mbuf_size,0},
 {recent_size,12},
 {stack_size,12},
 {old_heap_size,0},
 {heap_size,12},
 {bin_vheap_size,0},
 {bin_vheap_block_size,46422},
 {bin_old_vheap_size,0},
 {bin_old_vheap_block_size,46422}]},
 {garbage_collection,[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
 {min_bin_vheap_size,46422},
 {min_heap_size,233},
 {fullsweep_after,65535},
 {minor_gcs,0}]},
 {memory,2736}]
 
 %% 玩家进程从大富翁进程的ETS里面取出一个特别大的数据
 kitty_gen_server:make_tuple(100000).
 
 
 erlang:process_info(self(), [garbage_collection_info,garbage_collection,memory]).
 [{garbage_collection_info,[{old_heap_block_size,2586},
 {heap_block_size,514838},
 {mbuf_size,0},
 {recent_size,400006},
 {stack_size,26},
 {old_heap_size,179},
 {heap_size,514809},
 {bin_vheap_size,1},
 {bin_vheap_block_size,46422},
 {bin_old_vheap_size,4},
 {bin_old_vheap_block_size,46422}]},
 {garbage_collection,[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
 {min_bin_vheap_size,46422},
 {min_heap_size,233},
 {fullsweep_after,65535},
 {minor_gcs,4}]},
 {memory,4140216}]
 
 
 erlang:process_info(Pid, [garbage_collection_info,garbage_collection,memory]).
 [{garbage_collection_info,[{old_heap_block_size,0},
 {heap_block_size,514838},
 {mbuf_size,0},
 {recent_size,236348},
 {stack_size,12},
 {old_heap_size,0},
 {heap_size,400034},
 {bin_vheap_size,0},
 {bin_vheap_block_size,46422},
 {bin_old_vheap_size,0},
 {bin_old_vheap_block_size,46422}]},
 {garbage_collection,[{max_heap_size,#{error_logger => true,kill => true,size => 0}},
 {min_bin_vheap_size,46422},
 {min_heap_size,233},
 {fullsweep_after,65535},
 {minor_gcs,0}]},
 {memory,4119576}]
 
 Erlang进程间传递消息是采用复制的方式,可以看到上面玩家进程和大富翁进程内存都增加了
 这时调用一次大GC是比较好的做法
 erlang:garbage_collect().  默认是同步大GC
 erlang:garbage_collect(Pid).
 
 
 |