Michael Kublin has uploaded a new change for review.

Change subject: engine: Improving memory footprint for almost every command in 
the system
......................................................................

engine: Improving memory footprint for almost every command in the system

The custom properties is private case, so allocation of HashMap is required only
in small number of commands, benefit - we will not allocate thouthands of 
HashMaps
In case that we need a custom properties , map will be allocated

Change-Id: I266ac0abd5e53ec7c7948059ee575aac6b53c17b
Signed-off-by: Michael Kublin <[email protected]>
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/13423/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
index 73ce143..527c582 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
@@ -1,5 +1,6 @@
 package org.ovirt.engine.core.dal.dbbroker.auditloghandling;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -50,7 +51,7 @@
     private NGuid mUserId = Guid.Empty;
     private String mUserName;
     private String mVmName;
-    private final Map<String, String> customValues = new HashMap<String, 
String>();
+    private Map<String, String> customValues = Collections.emptyMap();
     private NGuid mVdsId;
     private String mVdsName;
     private NGuid mVmTemplateId;
@@ -441,18 +442,26 @@
     }
 
     public void addCustomValue(final String name, final String value) {
+        allocateCustomValues();
         customValues.put(name.toLowerCase(), value);
     }
 
     public void appendCustomValue(final String name, final String value, final 
String separator) {
         final String key = name.toLowerCase();
         String newValue = value;
+        allocateCustomValues();
         if (customValues.containsKey(key)) {
             newValue = String.format("%1$s%2$s%3$s", customValues.get(key), 
separator, value);
         }
         customValues.put(name.toLowerCase(), newValue);
     }
 
+    private void allocateCustomValues() {
+        if (Collections.EMPTY_MAP.equals(customValues)) {
+            customValues = new HashMap<String, String>();
+        }
+    }
+
     public Map<String, String> getCustomValues() {
         return customValues;
     }


--
To view, visit http://gerrit.ovirt.org/13423
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I266ac0abd5e53ec7c7948059ee575aac6b53c17b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Michael Kublin <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to