• 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
aregee

Instruments and memory usage going up without any leaks

2 posts in this topic

I launched Instruments for the first time, and had a play around.  I am happy to see that I have no leaks no matter how much I try to stress my application.  To verify that leaks are indeed detected, I removed one 'free()' to see if it detected that leak.  It did as expected.  I am also assuming that 'Live Bytes' and '#Living' are the numbers I am interested in if I want to see if my application is eating memory.

 

What I am observing is, that even if there are no leaks detected, there are groups of memory allocations that go up and up and up.

 

One that steadily increases is 'Malloc 64 Bytes'.  I was wondering about what that could be, since there is nowhere in my code that 'malloc(64)'.  At least not in a steadily fashion.  And it is not leaked!

 

I was thinking that maybe there is a GUI element that is exhibiting this behaviour.  The only GUI element I have that could fit this, is a NSSlider I have to track song position.  That was easily tested: I just paused the song, and the slider would stop updating.  The steady rise of 'Malloc 64 Bytes' stopped too.  Then I dragged the slider, and the number started to go up again.  In fact, I have found that usage of any GUI element exhibits this behaviour for allocations of various amounts of memory.  Nothing is ever leaked.

 

Is this some kind of internal optimisation that I don't need to worry about?  Is there any way I can stop this from happening?  What is really happening?  Will it eventually be freed during the course of my program?

 

If I have a closer look at which part of the program that is allocating this memory, I see an overwhelming amounts allocated from 'QuartzCore'.  Other names I see is 'AppKit', 'Foundation', 'Shortcut' and 'Core*' where '*' is 'Graphics' and 'Image'.

 

Responsible caller for 'QuartzCore' is 'CA::Context::commit_transaction(CA::Transaction*)'.

 

There is no part of my code listed as having allocated any of this memory.

 

0

Share this post


Link to post
Share on other sites

From: http://memo.tv/archive/memory_management_with_objective_c_cocoa_iphone

 

An autorelease pool is an instance of NSAutoreleasePool and defines a scope for temporary objects (objects which are to be autoreleased). Any objects which are to be autoreleased (e.g. objects you send the autorelease message to or created with convenience methods) are added to the current autorelease pool. When the autorelease pool is popped (released) all objects that were added to it are also automatically released. This is a simple way of managing automatic release for objects which are needed temporarily.

E.g. You want to create a bunch of objects for temporary calculations, and instead of keeping track of all the local variables you define and then calling release for all of them at the end of your function, you can create them all with autorelease (or convenience methods) safe in the knowledge that they are going to be released next time the autorelease pool is popped. Note: there is a downside to this which I'll discuss in the Convenience vs Explicit section.

Autorelease pools can be nested, in which case autorelease objects are added to the latest autorelease pool to be created (the pools are stacked in a Last In First Out type stack).

 

Do you have any auto release pools? If so they are probably in a context that doesn't get destroyed (such as main)

2

Share this post


Link to post
Share on other sites

From: http://memo.tv/archive/memory_management_with_objective_c_cocoa_iphone

 

An autorelease pool is an instance of NSAutoreleasePool and defines a scope for temporary objects (objects which are to be autoreleased). Any objects which are to be autoreleased (e.g. objects you send the autorelease message to or created with convenience methods) are added to the current autorelease pool. When the autorelease pool is popped (released) all objects that were added to it are also automatically released. This is a simple way of managing automatic release for objects which are needed temporarily.

E.g. You want to create a bunch of objects for temporary calculations, and instead of keeping track of all the local variables you define and then calling release for all of them at the end of your function, you can create them all with autorelease (or convenience methods) safe in the knowledge that they are going to be released next time the autorelease pool is popped. Note: there is a downside to this which I'll discuss in the Convenience vs Explicit section.

Autorelease pools can be nested, in which case autorelease objects are added to the latest autorelease pool to be created (the pools are stacked in a Last In First Out type stack).

 

Do you have any auto release pools? If so they are probably in a context that doesn't get destroyed (such as main)

 

I tried, but didn't see any difference.  I might have put it in the wrong place, but I noticed some other behaviour too.

 

I was watching the particular 'Malloc(64)' while I was playing a song, and the value just went up for half an hour.  64 bytes here and 64 bytes there doesn't really add up to much over a short duration.  I think it reached 750kB or something.  Then I decided to just let the music play to an end.  A little while later the allocations just dropped from about '#Live' 5000-ish to just 200.  That makes me think it is managed somehow.  And since I was playing the same song for half an hour without ever releasing it (NSInputStream), it really fits NSInputStream more than any GUI elements.  I will have a deeper look into that.  Thank you for your response!  Thinking about it, I think you are right about lacking a well placed autorelease pool.  You are certainly right about me only having an autorelease pool for main.

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