EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Page Faults

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#13403
Posted: 05/21/2010 08:50:00
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Hi all
I wrote a simple test application to copy a file to the virtual drive using 2 methods. The first method is to use CopyFile API and the second method is to use Read () and Write ().
I updated Mounter sample application to use FileStream instead of MemoryStream.
Then I launched the test application using Read () and Write () to copy a 9 GB file from C drive to the virtual drive.
When the file reached somewhere around 5 GB, my test application became unresponsive and throw an error. The error was due to the machine exhausting all its virtual memory. The OS displayed the message in the system tray as well. The machine became very sluggish and had to be restarted.
Please note that the use of the CopyFile () API does not create any problems.
I am using 2cpu Windows XP
RAM: 2GB
Virtual Memory = 2046 MB
CBFS: ver. 2.5.59.157
Any suggestions?


#13404
Posted: 05/21/2010 09:59:18
by Eugene Mayevski (EldoS Corp.)

You've run out of memory. Whee do you think the sample stores files?


Sincerely yours
Eugene Mayevski
#13405
Posted: 05/21/2010 10:50:15
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

The sample was saving files in C:\TEMP
Free space on C: is 130 GB


#13406
Posted: 05/21/2010 11:06:39
by Eugene Mayevski (EldoS Corp.)

I see that you've posted 61 message already. Do you have a license? If yes, please assign the license ticket to your user account before we continue. If no, you are welcome to purchase a license before we continue.


Sincerely yours
Eugene Mayevski
#13407
Posted: 05/21/2010 11:10:44
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Yes I have a license ticket.
#13408
Posted: 05/21/2010 11:26:40
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

OK, I assigned the license ticket to my account.
#13409
Posted: 05/21/2010 11:40:35
by Eugene Mayevski (EldoS Corp.)

Thank you. Can you please post the source code of your modifications (the complete source file) here so that out developers could check it?


Sincerely yours
Eugene Mayevski
#13410
Posted: 05/21/2010 11:44:53
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Which one ? the Eldos sample code or our test application.
#13411
Posted: 05/21/2010 12:26:52
by Eugene Mayevski (EldoS Corp.)

Your modifications of course :)


Sincerely yours
Eugene Mayevski
#13412
Posted: 05/21/2010 13:26:48
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Here is sample code modifications:

Code
        public VirtualFile(string Name)
        {
            try
            {
                mStream = new FileStream("C:\\Temp\\Test" + DateTime.Now.Ticks.ToString(), FileMode.Create);
                Initializer(Name);
            }
            catch (Exception e)
            {
                Console.WriteLine("Can not create file stream. Error - {0}", e.Message);
            }
        }

           private FileStream mStream = null;//private MemoryStream mStream            = null;


and here is the test application:

Code
// TestWriting.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "TestWriting.h"
#include "tchar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
   int nRetCode = 0;
   const DWORD buff_size = 1<<20; // buffer size is 1 MB

   // initialize MFC and print and error on failure
   if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
   {
      // TODO: change error code to suit your needs
      _tprintf(_T("Fatal Error: MFC initialization failed\n"));
      nRetCode = 1;
   }
   else
   {
      // TODO: code your application's behavior here.
      if(argc < 4)
      {
         nRetCode = 1;
         cout<< "Usage: TestWriting.exe <copy> <source_path> <dest_path>";
      }
      else
      {
         CString strSource = argv[2];
         CString strDest = argv[3];
         
         if(strcmp(argv[1], "1") == 0)
         {
            // Copy files
            if(::CopyFile(strSource, strDest, false))
               nRetCode = 0;
            else
               nRetCode = 1;
         }
         else if(strcmp(argv[1], "2") == 0)
         {
            // Get the extension
            CString strExtension = strDest.Right(4);
            CString strName = strDest.Left(strDest.GetLength() - 4);

            // Set the extension as .tmp
            CString strTempDest = strDest ;

            // Read and write files
            CFile cfRead, cfWrite;
            cfRead.Open(strSource, CFile::modeRead);
            cfWrite.Open(strTempDest, CFile::modeWrite|CFile::modeCreate);

            BYTE* buff = new BYTE[buff_size];
            DWORD bytesWritten = 0;
            DWORD spanCount = 1;

            while(cfRead.Read(buff,buff_size))
            {
               try
               {
                  cfWrite.Write(buff,buff_size);
                  bytesWritten = bytesWritten + buff_size;
               }
               catch(...)
               {
               }
               // Spanning just for convenience. Does not impact if spanning is not used.
               // Same behaviour will be seen.
               if(bytesWritten >= 4085760000) // 3990 MB
               {
                  // Close the main file
                  cfWrite.Close();
                  CString strSpanNumber;
                  strSpanNumber.Format("%i", spanCount);

                  // Create a new span file
                  CString strSpanDest = strName + _T("_") + strSpanNumber + strExtension;
                  cfWrite.Open(strSpanDest, CFile::modeWrite|CFile::modeCreate);
                  bytesWritten = 0;
                  spanCount++;
               }
            }
            cfRead.Close();
            cfWrite.Close();
            // Remove the .tmp extension.
            //::MoveFile(strTempDest, strDest);
         }
      }
   }
   return nRetCode;
}



How to use it:
TestWriting.exe 2 <source_path> X:\temp1.tmp
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 9929 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!