Hi Saima Saleem,
The error "std::bad_alloc: std::bad_alloc." could occur anywhere when the simulation reaches to a point that it cannot allocate any more memory. So if you see it happens with specific module, that doesn't mean there is error caused by the that module. At least, I see this point in my situation. But it is recommended that we should make sure our model is error-free, right?
Errors related to memory can be debugged using GDB or Valgrind, (I prefer Valgrind). So first you should profile your model using Profile As.. option in Omnet IDE.
If you make sure that your models are error-free, but it still crashes sometimes with "std::bad_alloc: std::bad_alloc", it is time to think about the OS used. I my case, before I used Ubuntu 12.4 32-bit, and it allows the RAM up to ~10% and the simulation crashes after that. Then I tried with Omnet 5.x, use Ubuntu 16.4 64-bit, now I can run up to ~100% RAM. So my advice is if you make sure the errors are not come from your models, just try 64-bit OS. But note that, there may be different between Linux and Windows. I also tried to run my models with Windows 10 64-bit, it it also crashes quickly when big RAM is required.
Hope this helps!
Danh