Click here to Skip to main content
15,035,723 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Let's say a variable is declared as "var x". Let's assume it occupies dynamic memory, i.e., SD RAM (Synchronous Dynamic RAM). If we never use that variable in real time, how can we save the memory occupied by that variable?
(Meaning of never use in real time is,assume that there is a variables Y and Z,from the external ports if we get inputs,say Y or Z,it is random that either Y has value or Z has value but we have memory can accommodate only one variable's space ,how can we do that?)

@Kemp,yes.its related embedded-DSP
Updated 21-Mar-10 7:31am

If the variable is never used then what's the point of declaring it? Just don't declare it.
vidhyacharan wrote:
Let's assume it occupies dynamic memory

Would it be your question context ? :) :
void ANeverUsedFunction(int iInput)
  int iNeverUsedVar = iInput; // this on-stack variable
                              // will be never allocated
                              // if the function will be not called 
There seem to be some terminology issues here.

Generally, when talking about software using dynamic memory for a variable, one is not talking about the physical type of memory that the variable is stored in. That is, one is not talking about the use of dynamic RAM vs. static RAM or magnetic cores or something else. Instead, the reference is to a method of dynamically allocating a region of memory to be used for the variable at run time rather than a more deterministic method setup at compile time.

Now in C or C++, a variable definition such as int x; does not use dynamic memory, though it may well be stored in dynamic RAM. Two different things.

Also, I'm not sure I know what you mean by never use that variable in real time.
Are you doing development on embeded micro-controller systems using C\C++ as this is really the only way your question makes sense to me?
Buy a basic book on C++, read it, and don't worry about things like this. You control memory by creating variables as you need them and using new and delete on pointers, that's all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900