The size of virtual storage is limited by the addressing scheme of the computer system and by the amount of secondary memory available and not by the actual number of main storage locations.
The book seems to assume (incorrectly) that you won't allocate virtual memory that you don't plan to use. So, it warns that the physical memory and hard disk used for swap limit the usable virtual memory (of course, from the perspective of your process, so do the other demands on that resource pool - the OS and other processes).
In practice, it's often useful to allocate more virtual memory than you could actually use, because you may want to, for example:
- use virtual memory for a sparse array, where you directly index in to a few scattered addresses,
- let the page faulting fail when the system resources actually run out, rather that complicating your code with some attempt to track available memory (remember this is dynamic with other processes etc.) or a pessimistic limit that means you fail to aggressively utilise your system capabilities
- let every program enjoy the benefits of believing it's been loaded at the address it was compiled for, so it can use absolute address for jump instructions etc. rather than relative
Relating that back to your specific questions:
1.[virtual memory is also limited by size of secondary memory] How?
Again, it's limited in the sense that attempts to use more will fail when memory - both physical and swap - is exhausted.
2.Is swapping( between main memory and secondary memory) a necessary condition for virtual memory ?
That's a little vague... virtual memory can only increase the overall amount of memory processes can transparently use by swapping physical memory content out to make space for new memory demands, and for reloading swapped-out content from the secondary memory. But, even if there's no swap disk space (and hence no swapping), or you don't have enough demand for memory to have done any swapping yet, processes can still benefit from virtual addressing as per sparse arrays, huge stack/heap areas with room to grow on demand, etc..
I mean if swapping is not allowed then still can we call it virtual memory though the benefits will be limited ?
Maybe. You can still benefit from virtual addressing, but it depends on whose terminology you adopt whether that classifies as virtual memory: there's a reasonable argument that "virtual memory" means you're pretending to have more physical RAM, so without the swap you wouldn't qualify even though you may be using the virtual addressing component supporting virtual memory.