Best of luck! One time I spent 3 weeks looking for the cause of that error, and it wasn't where I expected it to be. It could be *anything* which is wrong in your code, causing something else to go wrong (for instance, an attempt to use an array beyond its bounds, was often a cause of this for me, but sometimes it was other mistakes I had made). Containment is another strategy: cordon off parts of your code so they don't get used, and see whether it behaves any differently. But like I said before, bear in mind that containment doesn't prove that the error comes from the part you removed. One time my program worked fine when I was using 10,000 symbols, but when I increased to 50,000 symbols (I don't use IB's data feed) the error 504/509 happened, so it matters how much memory you are using because that makes more probability for your coding mistake to stomp on.