Memory escaping while using array reallocation.

Memory escaping while using array reallocation.

am 06.12.2004 10:55:00 von webmaster

Hi, everybody.

I'm wondering if I use next instructions:
while ( [some condition] ) {
my @array = (1,2,3,4,5,6);
... some code ...
@array = ();
}
then I hope Perl environment must be care about sufficient usage memory
zone, occupied by array allocation during first declaration (e.g. my @array
= (1,2,3,4,5,6);). Does it clean up all elements of array properly while
proccessing statement '@array = ()' ?

Thanks
, AZtpa



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Memory escaping while using array reallocation.

am 06.12.2004 16:47:17 von jose isaias cabrera

Hey, why take our word for it... try it. :-)


----- Original Message -----
From: "webmaster"
To: "Perl_sql"
Sent: Monday, December 06, 2004 4:55 AM
Subject: Memory escaping while using array reallocation.


> Hi, everybody.
>
> I'm wondering if I use next instructions:
> while ( [some condition] ) {
> my @array = (1,2,3,4,5,6);
> ... some code ...
> @array = ();
> }
> then I hope Perl environment must be care about sufficient usage memory
> zone, occupied by array allocation during first declaration (e.g. my
> @array
> = (1,2,3,4,5,6);). Does it clean up all elements of array properly while
> proccessing statement '@array = ()' ?
>
> Thanks
> , AZtpa
>
>
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe:
> http://lists.mysql.com/perl?unsub=jicman@cinops.xerox.com
>
>


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Memory escaping while using array reallocation.

am 07.12.2004 07:52:25 von webmaster

Hello, again.
You wrote:
[...]
> Hey, why take our word for it... try it. :-)
[...]
Good idea, but how about to use scoping rules:
while ( [some condition] ) {
{
{
my @array = (1,2,3,4,5,6);
... some code ...
} # local scope (inner level)
# the array have been cleaned up properly here
my @array = ();
... array manipulation instructions ...
}# local scope (outer level)
# the array have been cleaned up properly here
}# while

Thanks.
, AZtpa

Previous discussion :
> ----- Original Message -----
> From: "webmaster"
> To: "Perl_sql"
> Sent: Monday, December 06, 2004 4:55 AM
> Subject: Memory escaping while using array reallocation.
>
>
> > Hi, everybody.
> >
> > I'm wondering if I use next instructions:
> > while ( [some condition] ) {
> > my @array = (1,2,3,4,5,6);
> > ... some code ...
> > @array = ();
> > }
> > then I hope Perl environment must be care about sufficient usage memory
> > zone, occupied by array allocation during first declaration (e.g. my
> > @array
> > = (1,2,3,4,5,6);). Does it clean up all elements of array properly while
> > proccessing statement '@array = ()' ?
> >
> > Thanks
> > , AZtpa


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Memory escaping while using array reallocation.

am 07.12.2004 11:28:25 von Peter Pentchev

--+QahgC5+KEYLbs62
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Dec 06, 2004 at 12:55:00PM +0300, webmaster wrote:
> Hi, everybody.
>=20
> I'm wondering if I use next instructions:
> while ( [some condition] ) {
> my @array =3D (1,2,3,4,5,6);
> ... some code ...
> @array =3D ();
> }
> then I hope Perl environment must be care about sufficient usage memory
> zone, occupied by array allocation during first declaration (e.g. my @arr=
ay
> =3D (1,2,3,4,5,6);). Does it clean up all elements of array properly while
> proccessing statement '@array =3D ()' ?

Perl's garbage collection mechanisms guarantee that the memory allocated
for the members (scalars, if they are just 1, 2, 3, 4, 5, 6, or arrays /
hashes / objects referenced by the members, if they are not just
scalars) WILL be freed at some point in the future, but it does NOT
guarantee that it will be freed immediately. See the 'perlobj' page in
perldoc for details.

G'luck,
Peter

--=20
Peter Pentchev roam@ringlet.net roam@cnsys.bg roam@FreeBSD.org
PGP key: http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553
This sentence was in the past tense.

--+QahgC5+KEYLbs62
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)

iD8DBQFBtYXJ7Ri2jRYZRVMRAnfHAJ4r2WOySR1fk/vuSqpwxoCWP4vFAACd G0mS
xGN287LYF6Wb3JLPD5SGR5I=
=hFfu
-----END PGP SIGNATURE-----

--+QahgC5+KEYLbs62--