Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

I have one application written in MFC which fetches a some record set's from database with regular intervals, My problem is that onces the application is get started it couses the increase in sql memory and it does not release it.

I have check my mfc application for memory leaks but it dont have any memory leaks.
I google it, and i found some solution for this problem but that is not helpfull for me. what i want that When even i will close my application sql server should release the memory.

Please help me!
Posted
Updated 26-Apr-11 23:51pm
v2
Comments
Albert Holguin 25-Apr-11 21:24pm    
post some code and/or clarification, your question is too vague
LaxmikantYadav 27-Apr-11 5:44am    
Can you help me in this ?
LaxmikantYadav 26-Apr-11 7:53am    
The MaxServerMemory of sql server is set to 1GB, but sql server usage more than 1GB memory, so can you tell me how to prevent it.

Actually SQL server does not release memory when once it grabs ahold of it. I have written a little script that I use to release memory. However you should NOT run this on a busy server.

the 512 number can be changed to a lower number but be careful as you might crash your server with too low of a number.



USE master

EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE

EXEC sp_configure 'max server memory (MB)'

EXEC sp_configure 'max server memory (MB)', 512
RECONFIGURE WITH OVERRIDE

EXEC sp_configure 'max server memory (MB)'

WAITFOR DELAY '00:00:15';

EXEC sp_configure 'max server memory (MB)', 2147483647
RECONFIGURE WITH OVERRIDE

EXEC sp_configure 'max server memory (MB)'

EXEC sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
go

-Thomas Ross, pikitfense at h o t m a i l dot com
 
Share this answer
 
I don't know MFC. But, can you check if you are properly closing/disposing the connection objects? Also, have you thought of considering ConnectionPooling?
 
Share this answer
 
Comments
LaxmikantYadav 25-Apr-11 1:05am    
Yes, All Connections are closed in the application.
dan!sh 25-Apr-11 1:13am    
Sorry I don't understand that. Can you describe what you mean?
LaxmikantYadav 25-Apr-11 1:45am    
All the connection objects are properly closed/disposed in application..
LaxmikantYadav 27-Apr-11 5:44am    
Can you help me in this ?
Its also depend upon what driver you have used to connect the SQL server.
Please use SQL server OLE db driver and connector .
Since it is very flexible to allocate and releas memory objects.

It also depends upon what method you have used to pull out data from SQL server.

I suspect you should use Stored procedure and call that SP from within your code.

Please avoid looping thoruhg the record set .
It would be very nice if you set up one shot activity.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900