Advertisement



Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions

New Member?



 
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Development Discussions All developers who are coding games may stop by here for any help, suggestions, and everything development related.

Reply
 
LinkBack Thread Tools
Old 07-20-2008, 07:50 AM   #1 (permalink)
Zuner
 
Join Date: Dec 2007
Posts: 56
Reputation: 26
Default Zune Memory Usage Status?


I was just wondering if its possible to determine how much memory a game is currently using up or how much memory is available.






sableholic is offline   Reply With Quote
Old 07-20-2008, 08:55 AM   #2 (permalink)
zB Programmer
Jr. Member
 
DiNoGames's Avatar
 
Join Date: May 2008
Location: Bremen, germany
Posts: 454
Reputation: 246
Send a message via Skype™ to DiNoGames
Default

Code:
spriteBatch.DrawString(font, GC.GetTotalMemory(false).ToString(), new Vector2(10, 10), Color.White);
This shows the currently used memory. The GC (Garbage Collector) frees memory from time to time (usually when 1 MB of additional memory was allocated), so the printed value grows and shrinks with the garbage collector doing its work.
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.







DiNoGames is offline   Reply With Quote
Old 07-20-2008, 09:30 AM   #3 (permalink)
Jr. Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 392
Reputation: 121
Default

Quote:
Originally Posted by DiNoGames View Post
Code:
spriteBatch.DrawString(font, GC.GetTotalMemory(false).ToString(), new Vector2(10, 10), Color.White);
This shows the currently used memory. The GC (Garbage Collector) frees memory from time to time (usually when 1 MB of additional memory was allocated), so the printed value grows and shrinks with the garbage collector doing its work.
Is that in bytes or what? When I tried using it, it just seemed to just go up.



Tiptup300 is offline   Reply With Quote
Old 07-20-2008, 10:16 AM   #4 (permalink)
zB Programmer
Jr. Member
 
DiNoGames's Avatar
 
Join Date: May 2008
Location: Bremen, germany
Posts: 454
Reputation: 246
Send a message via Skype™ to DiNoGames
Default

Yes, its the amount of bytes... and it will drop down again when the garbage collector does its job.
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.







DiNoGames is offline   Reply With Quote
Old 07-20-2008, 10:25 AM   #5 (permalink)
Purger of Ignorance
zB Programmer
Section Staff
Super Zuner
 
Netrix's Avatar
 
Join Date: Jun 2008
Location: In my own world
Posts: 1,670
Reputation: 231
Send a message via MSN to Netrix
Awards Showcase
Favorite zB Extremity 
Total Awards: 1
Default

Quote:
Originally Posted by DiNoGames View Post
Code:
spriteBatch.DrawString(font, GC.GetTotalMemory(false).ToString(), new Vector2(10, 10), Color.White);
This shows the currently used memory. The GC (Garbage Collector) frees memory from time to time (usually when 1 MB of additional memory was allocated), so the printed value grows and shrinks with the garbage collector doing its work.
So then I suppose if you subtract that from 16 MBs, you can get an approximation of the amount of memory you have left.
__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter

Solitaire for your Zune!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.


Zune Book Reader!
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.




Netrix is offline   Reply With Quote
Old 07-20-2008, 10:54 AM   #6 (permalink)
Zuner
 
Join Date: Dec 2007
Posts: 56
Reputation: 26
Default

Quote:
Originally Posted by Netrix View Post
So then I suppose if you subtract that from 16 MBs, you can get an approximation of the amount of memory you have left.

You'd have to convert 16 MBs to bytes or convert that value to MBs, but yea. Thanks DinoGames.

Code:
//(16MBs in bytes - current bytes used)/bytes in a MB
            long mbsleft = (16777216 - GC.GetTotalMemory(false))/1048576;



sableholic is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -8. The time now is 09:06 PM.

 
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC8
vB Ad Management by =RedTyger=
(C) ZuneBoards 2006-2007
Copyright © 2006 - 2008 Zune Boards | About Zune Boards | Legal | A member of the Crowdgather Forum Community