Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 109049 - 2-dimensions char array not deleted
Summary: 2-dimensions char array not deleted
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High major (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://forums.gentoo.org/viewtopic-t-...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-12 13:17 UTC by NoZ
Modified: 2005-12-12 07:12 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description NoZ 2005-10-12 13:17:25 UTC
On a 2005.1 ~x86 Gentoo, when I try to destroy 2-dimensions characters array,
the memory is not freed (seen in 'ps' and 'free'.)

On other linux (Debian woody), there's no problem.

Current versions of the system tools :
sys-devel/gcc-3.4.4-r1
sys-libs/glibc-2.3.5-r2
sys-devel/binutils-2.16.1
sys-libs/libstdc++-v3-3.3.6
...

Reproducible: Always
Steps to Reproduce:
Try :

#define SIZE 5000000

// ...

int i = 0 ;
char ** hop = new char*[ SIZE ] ;

for ( i = 0 ; i < SIZE ; i ++ )
{
  hop[ i ] = new char[ 10 ] ;
  strcpy( hop[ i ] , "hophophop\0" ) ;
}

for ( i = 0 ; i < SIZE ; i ++ )
{
  delete[] hop[ i ] ; // this line doesn't seem to work
}
delete[] hop ;

// ...
Actual Results:  
When testing the memory usage while the program is running, after the
destruction of the arrays, the memory almost doesn't change.

Expected Results:  
Free normally the memory.

This problem is the same on 2 machines :
- P2 450Mhz, 478Mbytes RAM...
- P4 3.2Ghz, 1Gbyte RAM, running Gentoo under coLinux.

Portage 2.0.53_rc5 (default-linux/x86/2005.1, gcc-3.4.4, glibc-2.3.5-r2,
2.6.10-co- i686)
=================================================================
System uname: 2.6.10-co- i686 Intel(R) Pentium(R) 4 CPU 3.20GHz
Gentoo Base System version 1.12.0_pre8
dev-lang/python:     2.3.5, 2.4.2
sys-apps/sandbox:    1.2.13
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.20
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=i686 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT=""
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -march=i686 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo
http://gentoo.mirror.sdv.fr"
LANG="fr_FR@euro"
LC_ALL="fr_FR@euro"
LINGUAS="fr fr_FR"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="apache2 apm avi berkdb bitmap-fonts crypt eds emboss encode foomaticdb
fortran freetds gd gdbm gpm gstreamer gtk gtk2 imap imlib ithreads jpeg libg++
libwww mad memlimit mikmod mmx motif mp3 mpeg mssql mysql ncurses nls nptl ogg
oggvorbis pam pdflib perl png python qt quicktime readline samba sdl spell sse
ssl tcpd threads type1-fonts userlocales vorbis x86 xml2 xmms zlib linguas_fr
linguas_fr_FR userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LDFLAGS, PORTDIR_OVERLAY
Comment 1 SpanKY gentoo-dev 2005-10-12 16:38:39 UTC
my Debian chroot behaves the same as Gentoo ... tested gcc 3.3.x / 3.4.x / 4.0.x
in both systems

it could just be a cache feature of libstdc++ ... if you put it into a loop of
delete/free, the memory usage stays constant

while (1) {
  for (i = 0; i < SIZE; ++i) {
    hop[i] = new char[10];
    strcpy(hop[i] , "hophophop");
  }
  for (i = 0; i < SIZE; ++i) {
    delete[] hop[i];
  }
}
Comment 2 Mark Loeser (RETIRED) gentoo-dev 2005-12-12 07:12:34 UTC
Seems that's how it should appear.