Question

I'm working on a project which makes substantial use of code generation. Some of the files it generates contain >0.25 million lines of code. VS (2K5) doesn't cope too badly, but R# (4.01) throws an out of memory exception every two minutes or so.

Splitting them out into partial classes/separate files isn't an option in the immediate term, though it may be later.

Are there any clever IDE tricks to dealing with this?

EDIT: so people are immediately saying (very sensibly) 'don't have a file that big' and suggesting ways to break it out into smaller files.

That's fine, but I'm on a time-boxed task taking a look around and deciding what to optimise. My problem is very specifically 'how to view an insanely big file in an IDE without pain', not 'how to refactor the project'. For purposes of the question please imagine the file is read-only. :)

Was it helpful?

Solution

Seems like this R# tool (is that Resharper?) is the problem. Can you disable it? Otherwise, changing the file type for the generated code might make sense - presumably, you aren't going to be doing major editing on those files, so losing syntax coloring and other features specific to source files wouldn't be an issue.

OTHER TIPS

I would at least change huge files extention to something like .cpp_gen or .cpp_huge to remove syntax highlighting, outlining etc. and then reassign build tool back to C/C++ compiler tool for them.

WOW!

250 000 lines of code?

you should think not in a machine point of view, but in a human been point of view. Let's say that you want to pass that code to someone else, can you see the time to see what the code does?

Design Patterns were made to deal with this ind stuff, try to start small, refactoring it, then go deeper and start applying more D.P.

you will have less and less lines of code, and Yes, one of the best tricks is to separate into several files according to it's propose.

Assuming you're not hand-editing your generated code. (=BAD IDEA!!)

You could put the generated files in a separate solution that you compile from the command line and then reference those dll's from the project you're working in.

Is the problem when you open the file for editing in Visual Studio? I've noticed that VS editor can be quite slow and inefficient on large files. Also, you could try turning off certain options, e.g. word-wrapping kills my machine for some reason.

Otherwise you could use something else like Textpad with syntax highlighting installed to edit the problematic large source file... not as nice, for sure.

Don't use visual studio. There is too much going on in VS.

Since the file is read only, you wont be using any IDE features (Intellisense, Refactoring tools, formatting).

You will probably get better performance using a simpler application, such as notepad++ for simply viewing the file. Notepad++ will do standard language highlighting if you like color.

Can't you break up the files and use the preprocessor to bring them back together when you compile?

It must be possible somehow to group large chunks of those files in separate libraries. You'd then separate them into several projects. Tried this? What the is the current structure of your source code/ project?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top