Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd memory leak #1104

Closed
p5pRT opened this issue Jan 30, 2000 · 2 comments
Closed

Odd memory leak #1104

p5pRT opened this issue Jan 30, 2000 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 30, 2000

Migrated from rt.perl.org#2058 (status was 'resolved')

Searchable as RT2058$

@p5pRT
Copy link
Author

p5pRT commented Jan 30, 2000

From gerti@bitart.com

Created by gerti@bitart.com

The short program below leaks under various versions of perl and
on various OS. Am I missing something, or is this a bug in perl?

Thanks!

$x="TST00000";
while(1)
{
  my $handle=$x++;
  open($handle,'/etc/rc'); # or any other file
  close($handle);
}

Perl Info


Site configuration information for perl 5.00502:

Configured by gerti at Tue Mar 23 16:36:15 CST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=next, osvers=3_3, archname=i386-next
    uname='camelot '
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=NeXT DevKit-based CPP 3.1
    cppflags='-DUSE_NEXT_CTYPE -I/usr/local/include'
    ccflags ='-DUSE_NEXT_CTYPE -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-u libsys_s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/shlib /lib /usr/lib
    libs=-ldbm
    libc=/lib/libsys_s.a, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_next.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-nostdlib -r -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00502:
    /theUsers/gerti/Unix/lib/perl5
    /theUsers/gerti/Clients/Interfax/Distribution/INFax.3/lib
    /usr/local/lib/perl5/5.00502/i386-next
    /usr/local/lib/perl5/5.00502
    /usr/local/lib/perl5/site_perl/5.005/i386-next
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00502:
    HOME=/theUsers/gerti
    LANG (unset)
    LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
    LOGDIR (unset)
    PATH=.:/etc:/usr/etc:/theUsers/gerti/Unix/bin:/usr/local/bin:/usr/local/netpbm/bin:/usr/ucb:/bin:/usr/bin:/usr/sybase/bin:/theUsers/gerti/Apps:/LocalApps:/NextApps:/NextAdmin:/NextDeveloper/Demos:/usr/local/bin/ezmlm
    PERL5LIB=/theUsers/gerti/Unix/lib/perl5:/theUsers/gerti/Clients/Interfax/Distribution/INFax.3/lib
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh


@p5pRT
Copy link
Author

p5pRT commented Jan 31, 2000

From @gsar

On 31 Jan 2000 07​:46​:24 GMT, gerti@​bitart.com wrote​:

The short program below leaks under various versions of perl and
on various OS. Am I missing something, or is this a bug in perl?

Thanks!

$x="TST00000";
while(1)
{
my $handle=$x++;
open($handle,'/etc/rc'); # or any other file
close($handle);
}

You're filling up the symbol table with empty symbols (closed
filehandles). Create anonymous symbols with Symbol instead.

  use Symbol;
  while (1) {
  open(my $handle = gensym, '/etc/rc') or die;
  close $handle;
  }

In 5.6, you'll be able to shorten that to​:

  while (1) {
  open my $handle, '/etc/rc' or die;
  close $handle;
  }

Sarathy
gsar@​ActiveState.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant