cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c3b4a573a212a3db3ba496920e44688afe8f28f5

commit c3b4a573a212a3db3ba496920e44688afe8f28f5
Author: Cedric BAIL <[email protected]>
Date:   Wed Oct 29 06:15:11 2014 +0100

    evas: fix increased memory usage in Evas.
    
    Eina_Cow does memory comparison during standby time. So in expedite as we 
don't
    have any standby time, we end up allocating some vast amount of memory that
    will never be compared. It is way simpler to compare that the data are not
    going to change before hand. It should also reduce the CPU consumed during
    idle time.
    
    This patch save about 1MB of data at peak time in expedite.
---
 src/lib/evas/canvas/evas_object_image.c | 11 ++++++++---
 src/lib/evas/canvas/evas_object_main.c  | 15 ++++++++++-----
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_image.c 
b/src/lib/evas/canvas/evas_object_image.c
index 6a1b9e9..05e5fb8 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -280,11 +280,16 @@ Eina_Cow *evas_object_image_state_cow = NULL;
 static void
 _evas_object_image_cleanup(Evas_Object *eo_obj, Evas_Object_Protected_Data 
*obj, Evas_Image_Data *o)
 {
-   EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
+   /* Eina_Cow doesn't know if the resulting memory has changed, better check
+      before we change it */
+   if (o->cur->opaque_valid)
      {
-        state_write->opaque_valid = 0;
+        EINA_COW_IMAGE_STATE_WRITE_BEGIN(o, state_write)
+          {
+             state_write->opaque_valid = 0;
+          }
+        EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
      }
-   EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
 
    if ((o->preloading) && (o->engine_data))
      {
diff --git a/src/lib/evas/canvas/evas_object_main.c 
b/src/lib/evas/canvas/evas_object_main.c
index e5317e2..fded1ce 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -687,13 +687,18 @@ _evas_object_eo_base_destructor(Eo *eo_obj, 
Evas_Object_Protected_Data *obj)
           eo_do(proxy, evas_obj_text_filter_source_set(NULL, eo_obj));
      }
 
-   EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
-                        Evas_Object_Proxy_Data, proxy_src)
+   /* Eina_Cow has no way to know if we are going to really change something
+    or not. So before calling the cow, let's check if we want to do something 
*/
+   if (obj->proxy->proxy_textures)
      {
-        EINA_LIST_FREE(proxy_src->proxy_textures, texture)
-          eo_do(texture, evas_3d_texture_source_set(NULL));
+        EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
+                             Evas_Object_Proxy_Data, proxy_src)
+          {
+             EINA_LIST_FREE(proxy_src->proxy_textures, texture)
+               eo_do(texture, evas_3d_texture_source_set(NULL));
+          }
+        EINA_COW_WRITE_END(evas_object_proxy_cow, obj->proxy, proxy_src);
      }
-   EINA_COW_WRITE_END(evas_object_proxy_cow, obj->proxy, proxy_src);
 
    if (obj->cur->clipper) evas_object_clip_unset(eo_obj);
    evas_object_map_set(eo_obj, NULL);

-- 


Reply via email to