Thread overview
Out of memory?
Jan 24, 2004
Paul Runde
Jan 24, 2004
J C Calvarese
Jan 24, 2004
J Anderson
Jan 24, 2004
Paul Runde
Jan 24, 2004
yaneurao
Jan 25, 2004
Manfred Nowak
Jan 25, 2004
yaneurao
Jan 25, 2004
Manfred Nowak
Jan 25, 2004
Paul Runde
Feb 02, 2004
Walter
January 24, 2004
I've tried different variations of this:

class foo
{
   int   x;
   int   x1;
   int   x2;
   int   x3;
}

foo[] fooa;

int main(char[][] args)
{
   //fooa.length = 245760;
   while(1)
   {
      try fooa ~= new foo();
      catch
      {
         printf("Allocated %d instances of foo.\n", fooa.length);
         break;
      }
   }

   return 0;
}

This one creates 15360 instances of foo whether on a Win95 machine with 128MB or on a WinME with 256MB.  I searched the docs and could not find anything.  Also, setting the length of the array to anything over 245760 causes an Access Violation error.

What am I missing?

Thanks.
January 24, 2004
Paul Runde wrote:

> I've tried different variations of this:
> 
> class foo
> {
>    int   x;
>    int   x1;
>    int   x2;
>    int   x3;
> }
> 
> foo[] fooa;
> 
> int main(char[][] args)
> {
>    //fooa.length = 245760;
>    while(1)
>    {
>       try fooa ~= new foo();
>       catch
>       {
>          printf("Allocated %d instances of foo.\n", fooa.length);
>          break;
>       }
>    }
> 
>    return 0;
> }
> 
> This one creates 15360 instances of foo whether on a Win95 machine with 128MB or on a WinME with 256MB.  I searched the docs and could not find anything.  Also, setting the length of the array to anything over 245760 causes an Access Violation error.
> 
> What am I missing?
> 
> Thanks.

I don't think this is a limitation of D.  It may be a limitation of Win9X.  It probably also depends on the computer's available memory since each computer has a finite amount of RAM (even when you consider paging files).  I have 128MB of RAM and I was running several programs at the same time. (I'm running WinXP Home.)

This is what I got:
Allocated 1411072 instances of foo.

And I also got some friendly message boxes popping up telling me I was low on memory. And icons started disappearing.

-- 
Justin
http://jcc_7.tripod.com/d/
January 24, 2004
J C Calvarese wrote:

> Paul Runde wrote:
>
>> I've tried different variations of this:
>>
>> class foo
>> {
>>    int   x;
>>    int   x1;
>>    int   x2;
>>    int   x3;
>> }
>>
>> foo[] fooa;
>>
>> int main(char[][] args)
>> {
>>    //fooa.length = 245760;
>>    while(1)
>>    {
>>       try fooa ~= new foo();
>>       catch
>>       {
>>          printf("Allocated %d instances of foo.\n", fooa.length);
>>          break;
>>       }
>>    }
>>
>>    return 0;
>> }
>>
>> This one creates 15360 instances of foo whether on a Win95 machine with 128MB or on a WinME with 256MB.  I searched the docs and could not find anything.  Also, setting the length of the array to anything over 245760 causes an Access Violation error.
>>
>> What am I missing?
>>
>> Thanks.
>
>
> I don't think this is a limitation of D.  It may be a limitation of Win9X.  It probably also depends on the computer's available memory since each computer has a finite amount of RAM (even when you consider paging files).  I have 128MB of RAM and I was running several programs at the same time. (I'm running WinXP Home.)
>
> This is what I got:
> Allocated 1411072 instances of foo.
>
> And I also got some friendly message boxes popping up telling me I was low on memory. And icons started disappearing.
>
With windows XP you can  have a huge amount of virtual memory. Simply get a second hard rive and make a few GB virtual memory on each drive.  I think win95 wasn't (isn't) so flexible in this way.  Still virtual memory is slowwwww.

-- 
-Anderson: http://badmama.com.au/~anderson/
January 24, 2004
J Anderson wrote:
> J C Calvarese wrote:
> 
>>
>> I don't think this is a limitation of D.  It may be a limitation of Win9X.  It probably also depends on the computer's available memory since each computer has a finite amount of RAM (even when you consider paging files).  I have 128MB of RAM and I was running several programs at the same time. (I'm running WinXP Home.)
>>
>> This is what I got:
>> Allocated 1411072 instances of foo.
>>
>> And I also got some friendly message boxes popping up telling me I was low on memory. And icons started disappearing.
>>
> With windows XP you can  have a huge amount of virtual memory. Simply get a second hard rive and make a few GB virtual memory on each drive.  I think win95 wasn't (isn't) so flexible in this way.  Still virtual memory is slowwwww.
> 

Maybe for large collections I should be using class allocators?  But it is just odd that two machines with different OS versions and memory amounts would allocate exactly the same number of instances.  And I would have expected the results above, but neither machine complained.
January 24, 2004
In article <busj6v$2dl2$1@digitaldaemon.com>, Paul Runde says...
>This one creates 15360 instances of foo whether on a Win95 machine with 128MB or on a WinME with 256MB.  I searched the docs and could not find anything.  Also, setting the length of the array to anything over 245760 causes an Access Violation error.

it is a bug I had reported.

http://www.digitalmars.com/drn-bin/wwwnews?D/22303

and I wrote how to fix it.
by rebuilding phobos such as the following article, it'll be fixed.

http://www.digitalmars.com/drn-bin/wwwnews?D/21217

yaneurao.


January 25, 2004
yaneurao schrieb:

[...]
> by rebuilding phobos such as the following article, it'll be
> fixed.
> http://www.digitalmars.com/drn-bin/wwwnews?D/21217

Cannot rebuild phobos:
| std\thread.d(337): undefined identifier GetCurrentProcess

Where is the trick?

So long.
-- 
Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ 2EA56D6D4DC41ABA311615946D3248A1
January 25, 2004
In article <buv4go$aun$1@digitaldaemon.com>, Manfred Nowak says...
>Cannot rebuild phobos:
>| std\thread.d(337): undefined identifier GetCurrentProcess
>Where is the trick?

it needs forward declaration like this:

extern(Windows) export void* GetCurrentProcess();
// void* is an alias of HANDLE

yaneurao.


January 25, 2004
yaneurao wrote:

> it needs forward declaration like this:
> 
> extern(Windows) export void* GetCurrentProcess();
> // void* is an alias of HANDLE

thnx.
extern(Windows) export thread_hdl GetCurrentProcess();
played the trick.

So long.
January 25, 2004
yaneurao wrote:

> 
> 
> it is a bug I had reported.
> 
> http://www.digitalmars.com/drn-bin/wwwnews?D/22303
> 
> and I wrote how to fix it.
> by rebuilding phobos such as the following article, it'll be fixed.
> 
> http://www.digitalmars.com/drn-bin/wwwnews?D/21217
> 
> yaneurao.
> 
> 

That did the trick.  Thanks.

Paul
February 02, 2004
"yaneurao" <yaneurao_member@pathlink.com> wrote in message news:bustsi$2u0b$1@digitaldaemon.com...
> and I wrote how to fix it.
> by rebuilding phobos such as the following article, it'll be fixed.
>
> http://www.digitalmars.com/drn-bin/wwwnews?D/21217

I have the fix folded in now. Thanks.