the code you posted does not contain memory leaks that would be apparent to me. A static array can't really leak memory so the problem must be somewhere else but the code you posted is not enough to say where it is.
Also, can you elaborate on how exactly your program is acting crazy?