News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SysAllocStringByteLen limit

Started by jdoe, September 30, 2008, 06:09:55 AM

Previous topic - Next topic

jdoe


Hi,

I played with SysAllocStringByteLen Win32 API and I'm facing an allocation limit that vary when I use assembly, Office VBA and VB6.

With VB6 I can't go over 253,624,282 bytes
With Office VBA I can't go over 343,670,746 bytes
With assembly I didn't check precisely but it's a little bit over 1,000,000,000 bytes

Does someone have an idea why the allocations limit is not the same ?

Thanls

jdoe


hutch--

JD,

It is probably the way VB and OFFICE use OLE string, the other thing is they may be converting it to unicode which doubles the allocation. To add to the miseries I think the limit with OLE is OS version dependent. You must be dealing with very large data sets to reach these limits, could you do it with GlobalAlloc() instead ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jdoe

Quote from: hutch-- on September 30, 2008, 07:48:59 AM
You must be dealing with very large data sets to reach these limits, could you do it with GlobalAlloc() instead ?

hutch,

In fact, my question was for the documentation of a function I wrote as a replacement of the slow Space$() function. From time to time, I have to do developement on file importation system in Access databases and some files can be huge. I wanted to be sure of the file size limit I could handle.

But it's strange that VB can be aware of an external API call and change its behavior. On the other hand, Space$() suffer the exact same limit and is slow because the buffer is uselessly filled with spaces. Anyway, the files I deal with are far below that limit and as I said, it's more a documentation thing then anything else.

:U



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Create a string buffer. Limit of 253,624,282 bytes.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Returns the string buffer or an empty string on failure.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'in_lngSize : The size in bytes.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function BufferB(in_lngSize As Long) As String

    Dim lngPtr As Long

    lngPtr = SysAllocStringByteLen(API_NULL, in_lngSize)
    If lngPtr Then

        Call RtlMoveMemory(VarPtr(BufferB), VarPtr(lngPtr), 4&)

    End If

End Function