First (but this really should be a mere afterthought), your vague (ie, lacking specifics) description makes the overall process seem likely to be slow, or perhaps even to run out of memory, start thrashing to and from disk and make life miserable.
But the real answer is: you haven't told us enough to work with. What OS; what's a snippet of the code that produces the same failure look like; which widgets and have you calculated their overhead? etc. etc.
Please read On asking for help and How do I post a question effectively?