|
-
Oct 10th, 2024, 04:47 PM
#10
Re: Creating a large string in a private heap
If it's got to run on Windows 32-bit (as well as Windows WoW 64-bit), then stuffing the strings into any "far memory" isn't going to help any. And neither is LAA compiling/linking.
All the memory a 32-bit Windows machine will address is 4GB, so let's assume you've got one of these 32-bit Windows machine packed with memory. The Windows OS is going to take a sizeable chunk, and then all your "in-memory" services and start-up apps are going to take another sizable chunk. In total, that's probably, in some cases, going to approach 2GB. So, all that's left for VB6 is the remaining 2GB, which can be addressed with no concern about LAA linking.
Also, that entire 2GB is available to VB6 without any concerns of far memory, or private heap, or anything else. So, if you're getting out of memory (or out of string space) errors, about the only alternative is to start writing things to disk, and then reading pieces as you need them. That's sort of why we have disks in the first place.
In my primary application, I never had out of memory/string errors, but I was concerned about it. So, for all the 100s (if not 1000s) of places where I might show a MsgBox, I wrote a function that fetches the caption string from an MDB file. All these strings are just cross-referenced with a number (a Long). Because it's a MsgBox (which are basically never processor speed sensitive), there's no slowdown in my program whatsoever.
If you want me to, I'll post the little function that fetches these strings from the MDB file. Here's the gist of it, but I can post a more detailed explanation of it:
Code:
Public Function DbTxt(ID As Long, ParamArray sArgs() As Variant) As String
' If sArgs are passed, make SURE they're all strings.
'
Dim i As Long
'
rsStrings.Seek "=", ID
If rsStrings.NoMatch Then
If InIDE Then
MsgBox "IDE Development Error!!! The Strings.mdb message " & Format$(ID) & " wasn't found."
End If
Exit Function
End If
DbTxt = rsStrings![English]
'
' And now see if we've got any replacements to make.
For i = LBound(sArgs) To UBound(sArgs)
DbTxt = Replace$(DbTxt, "%%", sArgs(i), 1&, 1&, vbBinaryCompare)
Next
'
' The following is necessary because MS-Access strips trailing spaces and vbCrLf from any Text/Memo fields.
' It's a bit unusual, but it does happen, particularly trailing vbCrLf occurrences.
If InStr(DbTxt, "¶") <> 0 Then DbTxt = Replace$(DbTxt, "¶", vbCrLf, 1&, -1&, vbBinaryCompare)
If InStr(DbTxt, "§") <> 0 Then DbTxt = Replace$(DbTxt, "§", " ", 1&, -1&, vbBinaryCompare)
End Function
Oh, and just to say it, yeah, virtual memory may kick in to give us a bit more than 2GB, but, if we're that close, we truly need to be writing/reading stuff to/from disk.
Last edited by Elroy; Oct 10th, 2024 at 04:56 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|