OutOfMemory exception will be thrown only if you system bit size is not upto the level of size of object you use.
An OutOfMemoryException exception has two major causes:-
1.You are attempting to expand a StringBuilder object beyond the length defined by its StringBuilder.MaxCapacity property.
2.The common language runtime cannot allocate enough contiguous memory to successfully perform an operation