Good programming practice

Hi everyone, i have a doubt that is, when we do some like:
local game = true

this code is right, and i can put ; or no and the code run with or without ; but what we should do? put or no? other thing, i need some function to see what memory i am using etc, anyone have this function? and the last, what is the normal, great or bad about the values that this function can give me.
Thanks [import]uid: 26056 topic_id: 19331 reply_id: 319331[/import]

Programmers that come from C/C++ might find the use of “;” comfortable. But there is no need to use it in Lua. I personally don’t use it because it just adds an extra key stroke LOL :wink:

The following link shows how to get memory usage

http://blog.anscamobile.com/2011/08/corona-sdk-memory-leak-prevention-101/

[import]uid: 38820 topic_id: 19331 reply_id: 74578[/import]

Thanks for the help :slight_smile:

can say me the normal, great and bad values of memory?
some like

100-200=bad
50-100 = normal
20-50 = good [import]uid: 26056 topic_id: 19331 reply_id: 74580[/import]

I only look at the values to make sure there isn’t a memory leak. If memory keeps increasing and increasing you app or game will eventually crash.

As far as the amount of memory your using every app or game is different. I focus on performance rather than the total amount of memory I’m using. [import]uid: 38820 topic_id: 19331 reply_id: 74584[/import]

People have issues with scale maybe this will help.

There are two types of memory in our apps. Lua memory and Texture Memory. Lua memory is your variables, your tables and strings. Texture memory is anything big like an image, a sound or a sprite sheet.

The code that gets the Lua memory returns it in “Kilobytes” or in other words, you need to multiply it by 1024 to get the amount of memory in use.

The code that gets you the texture memory returns bytes, so you don’t need to multiply it by anything to get it on the same scale as the Lua memory.

Your phone or tablet probably has a minimum of:

 256,000,000 bytes of available memory up to   
1,024,000,000 bytes.   

Of course not all of that is free for your app, but you should reasonably have access to half that.

If the Lua memory is returning say 250 as its number, then its using:

 250,000 bytes. A trivial fraction of your available memory.  

Texture memory is what eats up large amounts of memory.

I don’t worry about the amount of Lua memory (returned by gcinfo()). What I worry about is it going up and and up and never going down. That’s the sign of a memory leak.

Your big leaks though are likely going to be blocks of texture memory and since they can on scale be in the:

 1,000,000+ range  

It doesn’t take to many of those to run you out of memory.

[import]uid: 19626 topic_id: 19331 reply_id: 74609[/import]