|
-
Apr 21st, 2023, 06:14 PM
#1
Thread Starter
Fanatic Member
Out of memory error
Hello!
I don't know why this is happening, but it happens like once a year until I do something specific.
When I try to add code or save it, it says "Insufficient memory".
Last time, I had to make 1 .bas file smaller by moving the code to a different module.
Another time, there was a problem with a .tlb. It took me days to find that out.
I have it again now, and I have no idea how I could investigate this.
I only had the idea of using procmon to see what it does when it happens.
Here is what it shows. The last entry is "CreateFileMaping C:\Windows\SystemREsources\imageres.dl.mun"

I have a really huge public enum with 1435 members, I am not sure if that might be the trouble.
Last edited by tmighty2; Apr 21st, 2023 at 06:18 PM.
-
Apr 21st, 2023, 06:48 PM
#2
Re: Out of memory error
If I remember correctly, there is a limit to the size (lines, I believe) of a single procedure. And, I believe, VB6 treats a module's header as a procedure. So yeah, your huge enumeration may be your problem.
Also, you posted in the CodeBank. I notified the moderators and I'm sure they'll move it shortly.
-----------------
ADDED: Yeah, it's apparently bytes. From the local MSDN:
When compiled, the code for a procedure can't exceed 64K.
ADDED2: I've never seen a limit on module size, and I've written a few large ones in the past.
Last edited by Elroy; Apr 21st, 2023 at 06:52 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.
-
Apr 21st, 2023, 07:33 PM
#3
Re: Out of memory error
You'd be hard-pressed to write a single procedure larger than 64K in code let alone compiled size, haha!
-
Apr 21st, 2023, 07:42 PM
#4
Re: Out of memory error
I've done it before.
It was for a pseudo-scripting language for my crazy overengineered file renamer. I had one function for all the tokens (which was easier to call recursively so they could be nested inside eachother like a(b(c),d) etc)... so implementations for Left, Right, Mid, InStr, and dozens upon dozens more, all surrounded by some boilerplate parsing code. Eventually I ran into the limit and split off specialized function groups (mp3 tag functions, EXIF functions).
-
Apr 21st, 2023, 07:51 PM
#5
Thread Starter
Fanatic Member
Re: Out of memory error
Perhaps this is some problem in my code:
' Note: Namespacing with VBA.Mid$ doesn't work properly here, throwing compile error:
' Function call on left-hand side of assignment must return Variant or Object
Mid$(json_Buffer, json_BufferPosition + 1, json_AppendLength) = CStr(json_Append)
-
Apr 21st, 2023, 07:58 PM
#6
Thread Starter
Fanatic Member
Re: Out of memory error
I even recorded my actions using a screen recorder, but it was so weird that I still don't understand why it works now.
After each restart of VB6, a different problem appeared. Always the same error "Out of memory", but pointing a different lines of code.
All starting with "VBA."
-
Apr 21st, 2023, 08:02 PM
#7
Re: Out of memory error
 Originally Posted by tmighty2
Perhaps this is some problem in my code:
' Note: Namespacing with VBA.Mid$ doesn't work properly here, throwing compile error:
' Function call on left-hand side of assignment must return Variant or Object
Mid$(json_Buffer, json_BufferPosition + 1, json_AppendLength) = CStr(json_Append)
Remove the "$" from "Mid$" if you want it to return a Variant as the error message suggests.
-
Apr 21st, 2023, 08:32 PM
#8
Thread Starter
Fanatic Member
Re: Out of memory error
Thank you. The enum wasn't the problem. I have split it into 2, but that didn't fix it.
-
Apr 21st, 2023, 08:52 PM
#9
Thread Starter
Fanatic Member
Re: Out of memory error
I have registered a dll, and so far the problem has not occured yet.
I will report back if it has.
C:\Windows\SysWOW64\regsvr32.exe MSSTDFMT.DLL
Got it from here: https://stackoverflow.com/questions/...f-memory-error
Last edited by tmighty2; Apr 24th, 2023 at 03:02 PM.
-
Aug 15th, 2024, 10:55 PM
#10
Thread Starter
Fanatic Member
Re: Out of memory error
I have finally found out what is happening.
I have too many enums or duplicates of enums or enums not distinct.
Which of the 3 I am not sure yet, but I can definitively say that enums are the culprit.
I started putting them into an external activex exe to make them available in my project, and the error is gone.
When I add them back into, I get the error immediately.
-
Aug 16th, 2024, 08:43 AM
#11
Fanatic Member
Re: Out of memory error
Put the enums on a spreadsheet and sort to see if you have duplicates.
-
Aug 16th, 2024, 09:06 AM
#12
Re: Out of memory error
WOW, I feel like quoting my own post #2, just to make the point again.
Per Microsoft, procedures can't be larger than 64kB. And the stuff in a module header is also consider a procedure, so that's also limited to 64kB.
Personally, it sounds to me like it's time for you to learn about TypeLibs, and throw all these Enums into a TLB file. Done that way, it completely circumvents any VB6 procedure size limits, and also makes your code much cleaner.
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
|