kofucii
kofucii

Reputation: 7653

Is my process memory constant?

It is an academic question. If I have a constant number of variables, objects, etc. And we assume that GC will not kick in, and there is no bottlenecks. Could some other factor force my application memory to fluctuate? In such a scenario would allocated by my process memory stay constant?

Upvotes: 0

Views: 138

Answers (3)

Jon Hanna
Jon Hanna

Reputation: 113352

It is possible, as in the sort of case mentioned in the question at How do these people avoid creating any garbage? to put a system into a state where it is working with a constant memory set and no GC is happening (because nothing is allocated that will need it to collect and it dies away to nothing). The article linked to even has a practical (but highly specialised) case.

Note that they have a large number of methods and classes they don't use that most of us would use every day.

Upvotes: 1

Ed Swangren
Ed Swangren

Reputation: 124760

Your scenario is contrived and unrealistic:

And we assume that GC will not kick in

Well, it will. Your application may take different paths during its execution. If it does, than the state can be different from time to time, references to objects on the heap may be kept around longer, etc. I don't really see the purpose of this question.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1039328

You could call unmanaged functions using interop which modify the amount of available memory. Also the JIT compiler might kick in at any moment to convert the IL to machine code and probably consume memory. Also assuming that GC won't kick in is not something which you can actually assume if you use .NET, so any conclusion you draw starting from a wrong assumption will be wrong. So to answer your question you cannot assume that memory will stay constant.

Upvotes: 1

Related Questions