elm image: Fix async open to avoid multiple mmap 90/151290/2 accepted/tizen/unified/20170929.081254 submit/tizen/20170928.042726
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:02:14 +0000 (08:02 +0000)
commit71107938d96a16f2a93db748dc84ea9504fd5c10
tree3eddf23248d1bcbca20f08796a356f3fcfa570ce
parentd61a068243968e75085be5b058334bde1024419b
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