elm image: Fix async open to avoid multiple mmap 41/151541/2
authorjiin.moon <jiin.moon@samsung.com>
Wed, 20 Sep 2017 10:18:07 +0000 (19:18 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 27 Sep 2017 08:03:32 +0000 (08:03 +0000)
commite4f817c3221883b0dc37b6c4c4e5f5fcc3259d9a
treebe773a528c3902f09d31d8c74818e66c250c79fb
parentddc897639d1b14a7c35a79ec3f38daa60498cdea
elm image: Fix async open to avoid multiple mmap

 From cb3b4cc8d7794bea575a85325c8a58f25f0507b2 Mon Sep 17 00:00:00 2001
 From: Jean-Philippe Andre <jp.andre@samsung.com>
 Date: Fri, 15 Sep 2017 14:39:14 +0900
 Subject: [PATCH] elm image: Fix async open to avoid multiple mmap

 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

Change-Id: If27d42b89269493ac2425737198338689687459d
src/lib/elm_image.c