I am reading postcodes from a csv file, taking that data and caching it with ets.
The postcode file is quite large (95MB) as it contains about 1.8 million entries.
I am only caching the postcodes that are needed for look ups at the moment (about 200k) so the amount of data stored in ets should not be an issue. However no matter how small the number of inserts into ets is, the amount of memory taken up by the process is virtually unchanged. Doesn't seem to matter if I insert 1 row or all 1.8 million.
# not logging all functions defs so it is not too long.
# Comment if more into is needed.
defmodule PostcodeCache do
use GenServer
def cache_postcodes do
"path_to_postcode.csv"
|> File.read!()
|> function_to_parse()
|> function_to_filter()
|> function_to_format()
|> Enum.map(&(:ets.insert_new(:cache, &1)))
end
end
I am running this in the terminal with iex -S mix
and running the command :observer.start
. When I go to the processes tab, my postcodeCache memory is massive (over 600MB)
Even if I filter the file so I only end up storing 1 postcode in :ets
it is still over 600MB.