From ad5aa5ac15e3df759a7044c6e9ecfd6282c2298a Mon Sep 17 00:00:00 2001
From: Thomas Tanghus <thomas@tanghus.net>
Date: Mon, 25 Jun 2012 17:16:34 +0200
Subject: [PATCH] Try to conserve some memory. Should fix oc-1106 for stable4.

---
 apps/contacts/ajax/contacts.php | 9 ++++++++-
 apps/contacts/index.php         | 8 ++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php
index 37d396cd83..45c54f90bc 100644
--- a/apps/contacts/ajax/contacts.php
+++ b/apps/contacts/ajax/contacts.php
@@ -11,7 +11,14 @@ OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 
 $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
-$contacts = OC_Contacts_VCard::all($ids);
+$allcontacts = OC_Contacts_VCard::all($ids);
+$contacts = array();
+foreach($allcontacts as $contact) { // try to conserve some memory
+	$contacts[] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'fullname' => $contact['fullname']);
+}
+unset($allcontacts);
+$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
+
 $tmpl = new OCP\Template("contacts", "part.contacts");
 $tmpl->assign('contacts', $contacts);
 $page = $tmpl->fetchPage();
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 74b7c43c55..994539e9fc 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -14,8 +14,12 @@ OCP\App::checkAppEnabled('contacts');
 
 // Get active address books. This creates a default one if none exists.
 $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
-$contacts = OC_Contacts_VCard::all($ids);
-
+$allcontacts = OC_Contacts_VCard::all($ids);
+$contacts = array();
+foreach($allcontacts as $contact) { // try to conserve some memory
+	$contacts[] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'fullname' => $contact['fullname']);
+}
+unset($allcontacts);
 $addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
 
 // Load the files we need
-- 
GitLab