Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi dear
I try to load a class 16000 times in my server
myclass[] Class = new myclass[4000,4000]
but when i load it outOfMemoryException will occur.
i programming in c# with XNA library and my operation system is windows server 2012 and my server has 32 gig ram. when that error occur 90% of these 32 gig ram are available.
Please help me.
Posted
Comments
Sergey Alexandrovich Kryukov 26-Sep-13 3:35am    
Help with what? Use less memory. There is no such thing as miracle.
—SA

There is no such thing as miracle. If you don't have enough memory, it's not enough.
It is possible to implement an array of objects using the disk file storage. But I strongly suspect you need to review all your architecture. You did not give us a clue why would you need so many instances of a single class, but I cannot believe you really need to use all of them at the same time.

—SA
 
Share this answer
 
Comments
Rick van Woudenberg 26-Sep-13 3:50am    
Well said. Nothing more to add.
Sergey Alexandrovich Kryukov 26-Sep-13 3:56am    
Thank you, Rick.
—SA
CPallini 26-Sep-13 3:59am    
5.
Sergey Alexandrovich Kryukov 26-Sep-13 4:09am    
Thank you, Carlo.
—SA
alireza ghasemi 26-Sep-13 4:04am    
thankyou very much but i want to know why it occur when i have more than 28 gig free ram in mr server.
is there any configuration or setting for defining max usage ram in servers?
  1. My abacus says 4000 * 4000 = 16000000, that is you are trying to create 16 millions instances of your class.
  2. Even on a 64 bit architecture, the CLR as a per object limit of 2GB, see this Stack Overflow question (it provides a workaround): "OutOfMemoryException on declaration of Large Array"[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Sep-13 4:10am    
The idea to "do the math" did not even visit my head. Great point, a 5.
By the way, we don't know, maybe the process is x86, executed on WoW64...
—SA
CPallini 26-Sep-13 4:13am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900