Home > Software engineering >  VB how to store and read a large amount of data
VB how to store and read a large amount of data

Time:09-24

For help: what has happened is that I have to create a large matrix to store the data, trigger a type of "System. OutOfMemoryException" exception

Do you usually how to deal with this problem?

CodePudding user response:

Do you know the 15000 x 150000 Double array need to how much memory?


About 167.64 GB!!!!!!
Are you sure your computer can have so much memory?

First of all, current home/office which can support the computer motherboard, I'm afraid there is no such a large memory;
Second, the only 64 - bit Windows system line (theory upward, not actual upward unknown),

CodePudding user response:

If there are so many the remaining space on the hard drive, using simulated memory file, speaking, reading and writing, speaking, reading and writing,
Reference API SetFilePointer

CodePudding user response:

1) call API to open the memory
2) new open memory
Can also, of course, with the file, database storage

CodePudding user response:

The public can also define a lot of data

CodePudding user response:

The building Lord, do work, the size of data to process? Directly on the Milky Way

CodePudding user response:

The building Lord, actual situation get with? Such as the database size could increase to 300 g, but I don't have to assign it a 300 g, from the start to allocate 100 m, and then increase slowly, and familiar with is essentially to know, in the enterprise manager by default in the form of an 10% growth, to the critical increases 10%, do not affect your function,

CodePudding user response:

The
reference 3 floor lm_whales response:

1) call API to open memory2) new open memory
Can also, of course, with a file, database storage

Novice thank you for your reply, I have no idea about the API, can give a little code memory? Thank you very much!

CodePudding user response:

You still use the database, the data quantity is too big

CodePudding user response:

Deposit 15000 records
Each record 15000 double should be no problem

CodePudding user response:

refer to the second floor zhao4zhong1 response:
if there are so many the remaining space on the hard drive, using simulated memory file, speaking, reading and writing, speaking, reading and writing,
Reference API SetFilePointer

Novice thank you for your answer, I have no idea about the API SetFilePointer, can give me a piece of code for reference? Thank you very much!

CodePudding user response:

 Const MOVEFILE_REPLACE_EXISTING=& amp; H1 
Const FILE_ATTRIBUTE_TEMPORARY=& amp; H100
Const FILE_BEGIN=0
Const FILE_SHARE_READ=& amp; H1
Const FILE_SHARE_WRITE=& amp; The H2
Const CREATE_NEW=1
Const OPEN_EXISTING=3
Const GENERIC_READ=& amp; H80000000
Const GENERIC_WRITE=& amp; H40000000
Private Declare Function SetVolumeLabel Lib "kernel32" Alias "SetVolumeLabelA" (ByVal lpRootPathName As String, ByVal lpVolumeName As String) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function SetFilePointer Lib "kernel32" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Private Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
Private Sub Form_Load ()
'KPD - Team 1998
'the URL: http://www.allapi.net/
'E - Mail: [email protected]
Dim sSave As String, hOrgFile As Long, hNewFile As Long, bBytes () As Byte
Dim sTemp As String, nSize As Long, Ret As Long
'Ask for a new volume label
SSave=InputBox (" both Please enter a new volume label for drive C: \ "+ vbCrLf +" (if you don 't want to change it, leave the blank) "textbox)
If sSave & lt;> "" Then
SetVolumeLabel "C: ", sSave
End the If

'Create a buffer
STemp=String (260, 0)
'Get a temporary filename
GetTempFileName "C: ", "KPD," 0, sTemp
'Remove all the unnecessary CRH $(0)' s
STemp=Left $(sTemp, InStr (1, sTemp, CRH $(0)) - 1)
'Set the file attributes
SetFileAttributes sTemp, FILE_ATTRIBUTE_TEMPORARY
'Open the files
HNewFile=CreateFile (sTemp, GENERIC_WRITE FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0 & amp; OPEN_EXISTING, 0, 0)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related