Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71304 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16990 invoked from network); 20 Jan 2014 08:00:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2014 08:00:45 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 108.166.43.123 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 108.166.43.123 smtp123.ord1c.emailsrvr.com Linux 2.6 Received: from [108.166.43.123] ([108.166.43.123:44274] helo=smtp123.ord1c.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/F2-02192-CA7DCD25 for ; Mon, 20 Jan 2014 03:00:44 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp8.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 71CDB1A0343; Mon, 20 Jan 2014 03:00:41 -0500 (EST) X-Virus-Scanned: OK Received: by smtp8.relay.ord1c.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 09B281A057D; Mon, 20 Jan 2014 03:00:40 -0500 (EST) Message-ID: <52DCD7A8.4090705@sugarcrm.com> Date: Mon, 20 Jan 2014 00:00:40 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Lin Yo-An , Daniel Lowrey CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: How to create Persistent zval? From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > And zend engine cleans up zvals at the end of request no matter the ref cnt > is? Yes and no. Zend Engine will clean up all emalloc-ed memory. It also will clean up all symbol tables, objects, resources, etc. that are stored in system tables. However, if you just create a zval structure with persistent pemalloc, it would not be cleaned - but you could not put this zval into any object, structure, etc., and passing it to engine functions may be dangerous too. If you're knowing what you're doing, you can pull it off (opcache sometimes does stuff like that IIRC) but you need to be extremely careful so that the engine does not store your zval and does not try to free it. > so zval is not persistent, then is HashTable persistent? > > It's because I need to store a zval object which has several properties. > Is there a way to do make the object persistent? Or do i need to serialize > it just like apc? Serializing it one way or another (doesn't have to be full serialize - serialize is pretty complex since it has to account for all corner cases, you can have something much simpler and use serialize handlers or custom code) may be the simplest way. It is possible to also keep objects in memory as is if you're very careful but it is not as simple to do it right. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227