delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/09/24/22:06:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <5.1.0.14.2.20020924185910.02c3d7c8@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
Date: Tue, 24 Sep 2002 19:06:22 -0700
To: cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: limit for # of items created with "new" ?
In-Reply-To: <amr1j5$b3$1@main.gmane.org>
References: <amqoqi$a3e$1 AT main DOT gmane DOT org>
<Pine DOT GSO DOT 4 DOT 44 DOT 0209241841560 DOT 7805-100000 AT slinky DOT cs DOT nyu DOT edu>
Mime-Version: 1.0

Hans,

That looks like over 80 megabytes just for the dynamically allocated "node" 
instances:

85000 * 30 * (8 + 8) * 2

If I understand correctly, all Cygwin app memory comes out of a single pool 
(hence the Cygwin heap size registry entry), so a proper accounting of 
available memory must take the other concurrently executing Cygwin 
applications into account.

Randall Schulz
Mountain View, CA USA


At 18:00 2002-09-24, Hans Horn wrote:
>Igor,
>
>"Igor Pechtchanski" <pechtcha AT cs DOT nyu DOT edu> wrote in message
>news:Pine DOT GSO DOT 4 DOT 44 DOT 0209241841560 DOT 7805-100000 AT slinky DOT cs DOT nyu DOT edu...
> > Don't forget the object headers - depending on which options you use, they
> > can be 8 bytes per object.  It would really help to see the source of the
> > crashing program, at least the snippet with the allocation and 
> dereferencing.
>
>Are there options that cost less (in terms of object headers) that the 
>defaults?
>
>Allrighty, here's the essence of what's going on:
>
>// compiled with : gcc -O2 tst.cpp -o tst -lstdc++
>// gcc version: 3.2
>
>#define NUM_POINTS 85000
>#define NON_ZERO      30
>
>// problem: have a collection of NUM_POINTS points,
>// - each point has attached ca 2800 byte descriptive info
>// - each point has two kinds (left and right) of neighbors.
>//   actual neighborhood of all points is given by a very sparse
>//      NUM_POINTS * NUM_POINTS matrix,
>//   having on average only NON_ZERO non-zero elements per row/column.
>
>#include <stdio.h>
>#include <iostream.h>
>#include <assert.h>
>
>// an element of a linked list
>typedef struct node {
>   node (int _v, node* _n) : v(_v), next(_n) {}
>   int   v;
>   node* next;
>};
>
>int main (int argc, char** argv) {
>   // allocate descriptions of points
>   char** points = new char*[NUM_POINTS]; assert(points);
>   for (int i = 0; i < NUM_POINTS; i++) {
>     points[i] = new char[2800]; assert(points[i]);
>   }
>   cout << "inited points[]" << endl;
>
>   // represent neighborhood for each point via linked lists :
>   node** adjl = new node*[NUM_POINTS]; assert(adjl); // neighbors to the left
>   node** adjr = new node*[NUM_POINTS]; assert(adjr); // neighbors to the 
> right
>   for (int i = 0; i < NUM_POINTS; i++) { adjl[i] = adjr[i] = NULL; }
>   for (int i = 0; i < NUM_POINTS; i++) {
>     for (int j = 0; j < NON_ZERO; j++) {
>       adjl[i] = new node(j, adjl[i]); assert(adjl[i]);
>       adjr[i] = new node(j, adjr[i]); assert(adjr[i]);
>     }
>     cout << "i " << i << ": total " << (i+1) * 2 * NON_ZERO << endl;
>     // last output: "i 29950: total 1797060"
>   }
>   cout << "inited adjl,r[]" << endl;
>
>   // process points[] and adjl,r[]
>
>   // clean-up
>
>   return 0;
>}
>
>Hans


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019