This is true, but for operations like loading images from disk for example, this is unavoidable. The best you can do is reuse memory instead of allocating whenever possible
Other than that, lag can come from many things, so if you lag without GC, the only solution is to profile that part of your app.