Question: I'm trying to make my very first game. Its a simple endless scroller 2D game build with Unity 4.3.4. and C#.

Everything works fine, but if you look closely, you can see it has tiny hiccups. When you look closely at the left, the particles not moving smooth at all.

What am i doing wrong? It looks like there is something wrong with the framerate or something.

Live version: <http://www.atticweb.nl/peekgame/> Download: <https://dl.dropboxusercontent.com/u/6929740/peekseek.rar>

---

Could it be i'm giving him forward motion with changing the velocity? :
rigidbody2D.velocity = new Vector2 ( speed, rigidbody2D.velocity.y )

Answer: 
EDIT: Thank you to [***Pascal***](https://stackoverflow.com/users/139746/pascal-cuoq) for his comment which is indeed correct! I have changed the answer as a result of this.

---

Using any optimization setting other than none, the compiler would optimize this function away *if it was statically defined* i.e., local to this compilation unit. With no optimizations turned on it might not. In that case the [***function prologue and epilogue***](http://en.wikipedia.org/wiki/Function_prologue), which are code that sets up the stack frame etc on entering the function, and destroys it on leaving, may still be emitted by the compiler.

As Pascal points out when it has external linkage this is not possible as the compiler doesn't generally "reach" across modules. However, in this case the linker should optimize it out if it detects that the function is not called.

Also it is completely possible to determine how much memory a function takes up. You can look at the [***elfdump***](http://www.unix.com/man-page/opensolaris/1/elfdump/)/[***objdump***](http://en.wikipedia.org/wiki/Objdump), or similarly appropriate utility, for the object that contains the function :)

---

To answer your question

> 
> If the function is called, then what is occupying the memory space? 
> 
> 
> 

A function must be compiled into [***machine code***](http://en.wikipedia.org/wiki/Machine_code). This is a set of instructions of architecture-dependent length/value etc that reside in memory. The computer fetches instructions from memory. Therefore your function must reside somewhere in memory for the CPU to be able to fetch it and then execute it. The C code your write is compiled into this machine code and it is this that takes up memory space...
Let's assume compiler doesn't omit out the given function, since it does nothing. And assume that compiler won't inline it either, since function is small. Your assertion that function doesn't do anything, doesn't call another function, no local variables, and not argument and return value - then why does it *would* require any memory?

First thing, the size occupied by function would be at two locations. One, at the generated binary (executable), and second, in the call stack of the thread which calls this function. An empty function would be sort of like a zero-byte file or a directory. Both *seemingly* doesn't occupy any storage in disk (since it is shown as '0 bytes'). But, they take some memory is the disk. 

Analogy of empty file is not exactly same as an empty function, just for understanding purpose, I wrote. A function would be called by some function (caller), hence **return-address** of that function would be kept in call stack (of current thread). When function ceases to exist, that return address would be looked up, and ESP would point to that location for next instruction.

Calling conventions would also add up more instructions, for empty functions, to clean up the call stack. Pascal calling convention, for instance, would have some more instructions to clean up the call stack when function exits. 

The bit-ness of the program (32-bit or 64-bit) would also change the size required for all this book keeping.