Giter Site home page Giter Site logo

Comments (10)

andersmelander avatar andersmelander commented on June 15, 2024 1

Ah... Yes of course; The cache is global and there's no lock on it.

This means that VPR_CACHE should not be defined by default. It should only be defined when one is sure that only one thread, at a time, will use VPR.

I will probably end up completely removing all the VPR_CACHE stuff since it didn't really provide the performance improvements I had hoped for.

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

I'll probably need a reproducible test case if I'm to anything about this. As you can see from the try...except you are not the first to get an overflow there.

from graphics32.

zedxxx avatar zedxxx commented on June 15, 2024

This try-except block is mine.

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

Ah :-) but still; Not the first.

from graphics32.

zedxxx avatar zedxxx commented on June 15, 2024

Undefining VPR_CACHE in GR32_VPR.pas fixes the issue. Is there something wrong with RenderPolyPolygon?

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

@zedxxx Did you delete a comment?

Is everything right here? https://github.com/graphics32/graphics32/blob/master/Source/GR32_VPR.pas#L579

Yes, as far as I can see it's okay - but I should have commented the code. It increases the allocated size in blocks of GrowSpanDataCacheSize.

if (Size > SpanDataCacheSize) then
begin
if (Size < MinSpanDataCacheSize) then
SpanDataCacheSize := MinSpanDataCacheSize
else
SpanDataCacheSize := (Size + GrowSpanDataCacheSize - 1) and (not (GrowSpanDataCacheSize-1));
GetMem(SpanDataCache, SpanDataCacheSize);
end;

from graphics32.

zedxxx avatar zedxxx commented on June 15, 2024

Yes, I realized that this is not the case.

BTW, GetMem on line 581 needs to be replaced with ReallocMem. Right?

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

BTW, GetMem on line 581 needs to be replaced with ReallocMem. Right?

Yes. You are right.

from graphics32.

zedxxx avatar zedxxx commented on June 15, 2024

Oh, its multi-threading problem (application use background threads to render bitmaps).

After replacing var with threadvar for global variables all works fine, but I'm not sure about the memory leaks.
Perhaps using TCriticalSection is the best solution here.

from graphics32.

andersmelander avatar andersmelander commented on June 15, 2024

Perhaps using TCriticalSection is the best solution here.

No because it's not only the allocation and reallocation that needs to be protected. It's also the content of the buffer. Only one rasterizer at a time can use the buffer, and locking the buffer while one thread is using it would effectively serialize rasterization.

from graphics32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.