|
-
Nov 18th, 2003, 10:36 AM
#1
Thread Starter
Hyperactive Member
How To Free Memory from my app?
Hello Everybody,
I want to know How To Free Memory from my app.
Thank you all in advance,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Nov 18th, 2003, 10:43 AM
#2
Frenzied Member
ehm
FROM your app? Release the memory the app uses?
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Nov 18th, 2003, 05:52 PM
#3
eranfox
We would need to see the app to see where you are keeping it. Can't do it by a Seance.
-
Nov 18th, 2003, 06:35 PM
#4
Hyperactive Member
My undersatnding is that there your app holds memory in two places the stack and the heap. Correctly me someone if I'm wrong.
Heap memory is for variables you declare only with a Dim statement such as longs, strings, integers.
Stack memory is for things you need to initialise with a Set statement such as recordsets, ado connections, dao databases.
Heap memory is released as soon as the function in which the variables were declared is exited, so you don't need to worry.
With stack memory the app releases any the memory the variable holds when it gets the chance to. So it may take a little while. You can get around this by setting any variables to nothing as soon at they you are finished with them. You should do this as a matter of course.
You also need to be conscious of where you are using memory. I once had to maintain an app that made a new connection to the database every time it needed to get data. This is highly memory intentensive. This sort of code needed to be replaced with a single database connection that the whole app could use.
Think also of big memory ticket items such as using local cursors. These bring all data into local memory, fast but expensive.
These are just a few things for you to think about. Post us with more details of the type of app you have
FW
-
Nov 19th, 2003, 10:32 PM
#5
PowerPoster
Heap hold anything declared global/public.
Stack holds basically everything else.
The short answer regarding freeing memory is:
1) all items pushed on the stack (eg. private functions, variables declared within, module level variables) are freed when they go OUT OF SCOPE (no longer using them).
1) unless you use the API, the only other memory you can normally free manually is arrays (see Erase) and objects (set object = nothing)
-
Nov 20th, 2003, 08:33 AM
#6
Thread Starter
Hyperactive Member
Reply
Hello Again,
I want to free memory - not the memory the app uses.
I'll explain:
Win98 dont know to free memory well
not like other OS such as winXP OR WIN2K
Because of that i want to be able to free/release memory by my self.
is that possible???
Thank you ALL,
best regards,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Nov 20th, 2003, 12:27 PM
#7
Frenzied Member
I once had to maintain an app that made a new connection to the database every time it needed to get data. This is highly memory intentensive. This sort of code needed to be replaced with a single database connection that the whole app could use.
Not true under COM+ (Win2k and later)
The database connection is pooled so that when you get the 'new' db connection you are actually simply retrieving the old one subject to time elapsed constraints.
This is actually one way to create very scalable components.
-
Nov 24th, 2003, 02:14 AM
#8
Thread Starter
Hyperactive Member
Reply
WELL???
I'm still waiting for your answers
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Nov 24th, 2003, 03:38 AM
#9
Frenzied Member
. . . and we're waiting for some manners.
-
Nov 24th, 2003, 10:13 AM
#10
Thread Starter
Hyperactive Member
Reply to yrwyddfa
Dear yrwyddfa ,
I'm Sorry if i hurt your feelings...
But...
I think we're missing the point here!
The point is
I'm still waiting for your answers
Thank you again for your reply,
Best Regards,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Nov 24th, 2003, 10:19 AM
#11
Frenzied Member
Well you shouldn't be so rude. We are not a service dedicated to serving you up with answers.
The answer you require is:
In VB you can't, and probably shouldn't unless it is a sideeffect of a native VB function.
If you want to have control of memory use GlobalAlloc on pre Win2k machines, and VirtualAlloc after Win2k to allocate yourself memory, and then you can do as you please with it.
How do these work? Well, there are tons examples all over the web.
-
Nov 24th, 2003, 10:21 AM
#12
Supreme User
Or do you mean freeing your app from memory?
VB Code:
Private Sub Form_Unload(Cancel As Integer)
'Free memory from app
Unload Me
'Terminate the app
End
End Sub
Is that what you mran? Or the other stuff as suggested above?
-
Nov 26th, 2003, 12:25 PM
#13
Thread Starter
Hyperactive Member
Reply to yrwyddfa
Dear yrwyddfa,
I'm sorry!!!
but you know,
sometimes the threads are going out of control.
the thread is about something but everyone trying to answer
about different subjects - this way we miss the threads issue.
Best Regards,
ERAN
have a nice day
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Nov 26th, 2003, 02:01 PM
#14
.NET probably manages memory better with its garbage collection, so you could switch.
On the other hand, what do you gain by managing memory? I would expect that you would have to have a fairly massive .exe for the VBVM not to load more .dlls into memory than your program itself. There are things you might do to save a few bytes here and there, but that probably does you no good.
Even with memory freeing, you would only be marking the memory as freed. To really benefit, you would want to consolidate freed memory. These days, for most apps, what's the point?
-
Nov 27th, 2003, 04:35 AM
#15
Frenzied Member
There are things you might do to save a few bytes here and there, but that probably does you no good.
On a system that is designed to scale massively, those few bytes add up to an awful lot of megabytes
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
|