Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15896 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69086 invoked by uid 1010); 7 Apr 2005 15:24:12 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69064 invoked from network); 7 Apr 2005 15:24:12 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 7 Apr 2005 15:24:12 -0000 X-Host-Fingerprint: 81.169.182.136 h59705.serverkompetenz.net Linux 2.4/2.6 Received: from ([81.169.182.136:41736] helo=strato.aixcept.de) by pb1.pair.com (ecelerity HEAD r(5268)) with SMTP id DE/B2-19272-B9055524 for ; Thu, 07 Apr 2005 11:24:11 -0400 Received: from baumbart.mbo (dsl-082-083-248-043.arcor-ip.net [82.83.248.43]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 367C835C271; Thu, 7 Apr 2005 17:30:22 +0200 (CEST) Date: Thu, 7 Apr 2005 17:24:11 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <862910842.20050407172411@marcus-boerger.de> To: Alan Knowles Cc: internals@lists.php.net In-Reply-To: <1112886653.19578.3.camel@alanportable2.hklc.com> References: <1112886653.19578.3.camel@alanportable2.hklc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] registering object constants leaking memory. From: mail@marcus-boerger.de (Marcus Boerger) Hello Alan, it seems you are registering constants on an internal class. If so you must use the correct api since your data must be allocated by malloc instead of emalloc. In your codes i can only see regular stuff that uses emalloc so it must go wrong. marcus Thursday, April 7, 2005, 5:10:53 PM, you wrote: > I'm using the code below to register object constants, however I'm > getting a memory leak on the line shown.. , any ideas how to avoid this? > /var/svn_live/dbdo/dbdo.c(401) : Freeing 0x0860FC34 (16 bytes), > script=examples/info.php > #define hash_add_assoc_long(__arg, __key, __val) > hash_add_assoc_long_ex(__arg, __key, strlen(__key)+1, __val) > int hash_add_assoc_long_ex(HashTable *arg, char *key, uint key_len, long > n) > { > zval *tmp; > MAKE_STD_ZVAL(tmp); // <-- 401 leaking here. > ZVAL_LONG(tmp, n); > return zend_symtable_update(arg, key, key_len, (void *) &tmp, > sizeof(zval *), NULL); > } > PHP_RINIT_FUNCTION(dbdo) > { > ..... > zend_hash_init(&dbdo_class_entry_ce->constants_table, 0, NULL, NULL, > 1); > /* fetch all returns */ > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "OBJECTS", > 0); > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), > "KEY_VALUE", 1); > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "VALUE", > 2); > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "SINGLE", > 3); > /* update/delete build or use fetchedobject. */ > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "BUILD", > 1); > /* error constants */ > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "E_ALL", > 3); > hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "E_FULL", > 63); > .... -- Best regards, Marcus mailto:mail@marcus-boerger.de