Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411613 Posts in 69390 Topics- by 58447 Members - Latest Member: sinsofsven

May 09, 2024, 06:40:56 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Memory consumption troubles in .NET C#
Pages: [1]
Print
Author Topic: Memory consumption troubles in .NET C#  (Read 1593 times)
stringkiller
Level 1
*


Fat Pixel


View Profile
« on: May 16, 2010, 04:59:47 AM »

Hello everybody I'm new to this forum and I, along with a friend started an indie game creation proyect some time ago.

We decided to write a "tower defense" game on C# using DirectX libraries, and just as the game is almost finished we noticed it consumes about 100mb of memory space, wich happens to be quite a lot.

We were thinking on making much bigger games after that, and we don't really know if this is going to be a problem, as this game we are making now doesn't even have sound, but all the textures (it's 2D) are 24bit Pngs.

Is there any way to reduce the memory usage or to know if a larger proyect game will take so much memory that would be unplayable on standart machines?

Also, would it be difficult to learn C++ if you are good using C#? we were thinking on doing future proyects on C++ due to this memory issue, but we don't know if the usage of classes and objects would be much different.

thank you very much for your time!
Logged

< check out the devlog! or Twitter!
increpare
Guest
« Reply #1 on: May 16, 2010, 05:28:02 AM »

Welcome to the forums.  Don't forget to introduce yourself first.  I don't know about memory issues and C sharp, so I can't answer your memory question.  As for using C++ if you know C sharp, yeah I think it's definitely doable - there're lots of minor considerational changes, but most knowledge can be transferred over without too much violence.
Logged
raigan
Level 5
*****


View Profile
« Reply #2 on: May 16, 2010, 05:46:04 AM »

100mb doesn't sound like too much; firefox uses more!
Logged
Toeofdoom
Level 2
**



View Profile WWW
« Reply #3 on: May 16, 2010, 06:00:25 AM »

100MB isn't ridiculous, based on the information you've given. My first EGP game was a whopping 63MB, probably textures for the most part and it was written in C++, though I admit that number surprises me a little. What size are the PNGs (1024x1024? etc) and how many of them are you loading? If you find certain PCs like netbooks have issues, just load smaller versions of the textures on them.

I think many games use techniques that lower bit depth of images without extreme impacts on quality, such as DXT1 and DXT5 - you could research them if you like.

Point is, as much as I like C++ I don't think C# is the problem here. If there even is a problem.
Logged

muku
Level 10
*****


View Profile
« Reply #4 on: May 16, 2010, 01:21:51 PM »

One point: if you are just loading the PNGs into DirectX textures in order to display them, you can release them from main memory once they're uploaded onto the GPU, and then they won't show up in the Task Manager's memory column at all (if this is how you checked your memory consumption). Maybe you don't free them for some reason?
Logged
stringkiller
Level 1
*


Fat Pixel


View Profile
« Reply #5 on: May 17, 2010, 01:47:31 PM »

Thanks for all your answers guys. We've finally found the problem. It seems that the program just stacked all the memory it could until it found it didn't have any more left on the system, we found that out by checking out the program just growed and growed the more time we tested it... probably when it reach the limit it would free some memory so it could still run.

Finally we realized that with the "SetWorkingSet();" function we could limitate the memory used by the game, we just tried a few with really complex levels until it didn't crash and it turns out that you can play it perfectly with about 8mb, and since C# takes quite a lot of memory just creating the form, the game itself doesn't really spend much memory.

I've also tried the DXT5 textures and for those who are interested in perfect 2D graphics with different levels of alpha this isn't very good as the textures loose a lot of quality, but the ARGB24bits works just fine.

We are considering moving to C++ for later projects using different graphic libraries.

thanks a lot again for your answers, soon we'll post around here a new C# custom tower defense game with a level editor, wich happens to be this game! it's in spanish though I don't know If we'll translate it or not but it is pretty easy to understand with a proper readme fil  Smiley
Logged

< check out the devlog! or Twitter!
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic