• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Tallkotten

Most memory effective way to do this

3 posts in this topic

Hello!

I'm in need of help. I am about to build a system that displays info about an item on the screen and i need some help to understand which of 2 ways is the most memory effective.

So basically in my game i am making there are items on the ground. If the player holds down CTRL he/she gets up an UI that draws out the stats and name of the item.

I currently got a sloppy but functional system and i want to improve it. I got 2 ways in mind.

First way:

First create a object of the class in the initiation:
[CODE]
ItemInfo* UI = new ItemInfo();
[/CODE]

And then when i want to draw something new i contact the build function in the class to update it.
[CODE]
UI->build(all the variables);
[/CODE]

When i want to show it i switches a bool which makes it draw on the screen. I switch the bool to false when i want to hide it.

[b]This way the UI is basically always gonna be on the screen (in the memory), just invisible to the user most times.[/b]

Second way:

When i want to draw the UI i create a new object of the class and sends all the necessary variables with it.
[CODE]
ItemInfo* UI = new ItemInfo(all the variables);
[/CODE]

Then if i don't want to show it anymore i delete the object and set the pointer to NULL
[CODE]
delete UI;
UI = NULL;
[/CODE]

If i want to show it again/update it i recreate it again, but with different variables. Of course if it isn't deleted already i have to do that first
[CODE]
ItemInfo* UI = new ItemInfo(all the variables);
[/CODE]

I show it if the pointer != NULL, if it is NULL I don't try to draw it (since there isn't anything to draw)

[b]This way is more memory and CPU intense when i am showing itemInfo but the memory is freed when i ain't doing anything with it.[/b]

Which way is more effective?
0

Share this post


Link to post
Share on other sites
How often will you be displaying item info? If it's reasonably often, if there is almost always some item info on-screen, and if the item for which info is being displayed changes frequently enough, then you should probably accept the extra memory overhead, otherwise you're looking at a potentially bad run-time bottleneck.

Even if not, you should definitely be profiling memory usage to determine if you are or are not worrying overmuch about something that may not even be a problem. Even if you've got a coupla extra MB usage, this is almost totally insignificant by todays standards - the days of having to be ultra-frugal about memory usage, and when memory usage was highly likely to be a major program bottleneck, are over.

That's not an excuse for going nuts or doing stupid things; it just means that focussing solely or even primarily on memory usage is not as important as it used to be.
1

Share this post


Link to post
Share on other sites
Take the first approach. Instanciate all the widgets you need and display them ,when needed. There's no reason to create/delete them all the time.
2

Share this post


Link to post
Share on other sites
[quote name='mhagain' timestamp='1343912301' post='4965508']
How often will you be displaying item info? If it's reasonably often, if there is almost always some item info on-screen, and if the item for which info is being displayed changes frequently enough, then you should probably accept the extra memory overhead, otherwise you're looking at a potentially bad run-time bottleneck.

Even if not, you should definitely be profiling memory usage to determine if you are or are not worrying overmuch about something that may not even be a problem. Even if you've got a coupla extra MB usage, this is almost totally insignificant by todays standards - the days of having to be ultra-frugal about memory usage, and when memory usage was highly likely to be a major program bottleneck, are over.

That's not an excuse for going nuts or doing stupid things; it just means that focussing solely or even primarily on memory usage is not as important as it used to be.
[/quote]

Well that depends on the player. But imagine Diablo, there you look at the stats a whole lot. Or WOW, where you check your stats on items a lot as well.

[quote name='Ashaman73' timestamp='1343912558' post='4965510']
Take the first approach. Instanciate all the widgets you need and display them ,when needed. There's no reason to create/delete them all the time.
[/quote]

Guess i'm going with the first option. I were aware that it might no make any difference since like you said there is a lot more memory to work with today, but i always feel that i want to do it "the right way" with as little sloppiness as possible [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]

Thanks for a quick reply you both! :) Edited by Tallkotten
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0