• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# memcpy faster in debug mode

This topic is 5884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

MSVC++ 6.0 I''m using memcpy() to copy 600kb of data from system memory to system memory. I do this once every frame in my "game". When I compile and run the program in Debug mode it runs faster than in Release mode. (I can see a slow down in the frames per second counter, like 20%) Anybody knows why?

##### Share on other sites
a better benchmark would be to time just memcpy call.

##### Share on other sites
Thanksª, I did it and I found the problem wasn''t there.

The problem is here:

  	if(m_lpDDSLockable->Lock(NULL, &m_ddsdBack, DDLOCK_WAIT, NULL) == DD_OK)	{		m_wPdds = (WORD *) m_ddsdBack.lpSurface; 		memcpy((void*)(m_wPdds),(const void*)(m_GfxData.pData),m_GfxData.Size);	}	m_lpDDSLockable->Unlock(NULL);

I Lock a DDRAW surface and then I do a memcpy from System Memory to Video Memory. This are the timings:

Debug Mode : 4 milliseconds
Release Mode : 6 milliseconds.

I don''t know why this happens. Can you see something wrong here?

##### Share on other sites
This is shot in the dark, but maybe you have different optimization options set for the debug and release profiles.

##### Share on other sites
yes, 0.004 and 0.006 are very small numbers.

do some bigger tests

##### Share on other sites
quote:
Original post by petewood
This is shot in the dark, but maybe you have different optimization options set for the debug and release profiles.

Oh, I wish. I''m using the default options. There isn''t too much to touch in the compiler window. I tried activating and deactivating some stuff but the problem remains.

quote:
Original post by petewood
yes, 0.004 and 0.006 are very small numbers.
do some bigger tests

The difference of 2ms becomes 20% less frames in one second. The most incredible thing is that Debug mode is faster than Release mode. I''m sure the problem arises when I do a memcpy() from system to video memory. I think I should desist trying to do it and just work with video memory.

##### Share on other sites
You stated exactly why this is happening; you are coppying from system memory to video memory. If I recall correctly, in Debug mode, DDraw puts ALL surfaces in system memory, so your memcpy is faster (system memory to system memory).

##### Share on other sites
quote:
Original post by Anonymous Poster
You stated exactly why this is happening; you are coppying from system memory to video memory. If I recall correctly, in Debug mode, DDraw puts ALL surfaces in system memory, so your memcpy is faster (system memory to system memory).

Mmmm, I don''t think so. When I look the free video mem after creating every surface I see the video mem going down, so I belive the surfaces are being created in video mem.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634072
• Total Posts
3015341
×