Reported by @jiin.moon:
In case of async_open for an elm_image, we try and open a file in a
thread, then map it and populate a bit, as this may take some time
(blocking I/O). This creates a mmap with eina_file_map_new. But later
evas image loaders will (usually) try and map the entire file with
eina_file_map_all() which creates another mmap. Since the size is
different (32Kb first then all) the returned map might be different
(it's up to the kernel to decide at this point).
So, in order to avoid having multiple maps on the same file, and try to
reduce the peak memory usage, we should prefer using the same map all
the time, i.e. the global one returned by eina_file_map_all().
This patch relies on the previous patch in eina_file which fixes
eina_file_map_populate() for the global map.
@fix
// blindly load in here to let's say 32KB (Should be enough to get
// image headers without getting to much data from the hard drive).
size = size > 32 * 1024 ? 32 * 1024 : size;
- map = eina_file_map_new(f, EINA_FILE_POPULATE, 0, size);
+ map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
+ eina_file_map_populate(f, EINA_FILE_POPULATE, map, 0, size);
if (ecore_thread_check(thread))
{