?
Solved

How I can adjust Windows XP,so my program always stay in memory and NOT move to swap file?

Posted on 2005-03-10
5
Medium Priority
?
201 Views
Last Modified: 2010-04-17
Hellow Experts !
I has some dificult qustions – and need of your help !

I am writing software that assists to copy/move of real big files by fast 1 000 MB LAN. The size of files is larger – form 50 MB to 10 GB ! So after I copy about 1-2 GB Windows sets all RAM for copy process and kick up RAM, used in my software. In result – my application needs of some seconds in range 8-15 to become accessible :(

I have tried with many RAM – 1 GB –it improves response time, but not good enough. So I think that solutions must be in software.

I use Windows XP Pro (with SP2) or Windows 2000 (with SP4). I can NOT use Windows 2003 server.  To copy files my application use ActiveX – Microsoft  file system object.

So how can I order to windows to NOT move to swap file RAM, used form my software? May be some API that I can use? I use Visual Basic 6.0 with SP5, but can work and with C++.

I will be thankful to any help!
0
Comment
Question by:dvplayltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
fatalXception earned 1500 total points
ID: 13504467
I'm not sure that you can (or should) do this. The Swap file is there for a reason, and other applications might not like having access to it removed. Plus, in terms of windows programming, access to memory is totally abstracted from you (protected mode) - if you as for an array of 10,000 integers to be allocated, you can never tell if that's all in RAM, or in the swap file, etc. Windows automatically chooses for you.

You could limit the size of the swap file in Windows to try to force Windows to use physical memory, but that's putting a lot of pressure on the system, again if other applications (including Windows) need to use it  or RAM you would actually see degraded performance, instead of an increase.

Are you sure you could not solve your problem by looking at the copying routine that is being used - for example if fix the amount of memory that is usable by the file copy process, that is to say, decide that you will copy the files in 128MB chunks. That way if you are running 4 of these processes side by side, the most memory in use at any one point is 512MB + overhead for code, but it won't increase because you don't let it.

If you opted for this method you could stop using the FSO and write your own binary file copying utility, which would give you total control over how much memory is being used to copy the files, even with multiple processes running the same code.
(By writing your own binary copying utility I mean that you would write your own cut-down FSO which you have more control over, which would allocate buffers dynamically in memory and read a chunk from the source file into the buffer, send the chunk down the wire, release the chunk, read another chunk...and so on.
The only downside is that you'd need a program on the other end of the wire to accept these chunks, but I still reckon this is the most memory friendly way if you have multiple copies going on.)

)
0
 

Author Comment

by:dvplayltd
ID: 13504549
Thank you fatalXception.

For me copy process is NOT time critical. I prefer to delay it, than windows kick up RAM, used for my application.
It is a good idea to read and write a chink of file. In that way I can control RAM byffer and speed of copy, used to copy process. Idea is good, but I must write many code for this. I will wait some days to see if their some APIs or registry changes.
What buffer you suggest for WinXP Pro for :
   * PC with 512 RAM
   * PC with 1 GB RAM ?

I do NOT want to control memory - I just want my application to stay always in memory. For example - I can assing to my software HIGH priority (for CPU). Why I can NOT make same with RAM ? My software do NOT use many RAM so performance will be unaffected ram.
0
 
LVL 8

Expert Comment

by:fatalXception
ID: 13504750
The reason you can't tell Windows "i want to use X amount of physical RAM and not Swap file" is just because of the way it is designed - I suppose they wanted to makre sure that no one application could hog all of the memory and force the others to live off the (slower) swap file.

In terms of buffer sizes, the best way to decide how much you can afford to allocate at any one time it to check the normal memory usage of your system, and see how much RAm is free furing normal usage.
Then decide hw many processes you want to run, leave 50MB of RAM free for other apps/your app , and divide what's left by the buffer count, this is the biggest size you can safely use per buffer without forcing a swap file access.

e.g if you have 300 MB free, and want 4 buffers
(300-50) / 4 = 62.5 so you could stretch this to 64MB/buffer and have enough space to run your app as well., without forcing swap file access

But remember, if in the meantime another app starts up, and is using a lot of RAM, you may end up being forced into the swap file sometimes.
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13522788
Detect how much memory is available and how much ram in total and create a ram drive taking into consideration the amount of ram so that you dont over use RAM. Then you can use that. I have seen some questions on here which are most likely now PAQ's with regards to RAM drives and how to use them. These are in the visual basic TA so have a search around on here for them :) Not sure if that is of any use :-S Just thought I would stick my 2 cents in though :)
0
 

Author Comment

by:dvplayltd
ID: 13523337
I do NOT think that RAM drive will slow thinks.

I read more - the problem is that "File Cache Management" give all memory to file cache and kick up many of RAM used in software to swap. Then when you need of software - it takes some seconds to move it RAM from swap to memory.

I think that control (limit) of RAM, used form File Cache Management is the rigth way. However - I can NOT find how to do it.

Are anyone know some registry settings or other that can I use ?



0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Make the most of your online learning experience.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question