[Autogenerated] In the Next example, we'll take this function.
And duplicate it.
And then change some things.
So what I want to do here, is to create a single object,
can be anything really but just one.
So it doesn't matter which object I'm actually creating.
But I'll try, to duplicate the handle as many times as I possibly can,
which means creating more and more handles pointing,
to the same exact project project So we expect here the memory consumption,
to be very low, but still we should be getting to the maximum number of handles.
That the process would allow.
So let's see how that works in terms of the duplicate handle.
API duplicate handle, API is something we'll take a deeper,
look later on in this course.
But let's do something very simple by duplicating,
an existing handle, to our own project access here.
So here, is going to We're going to have a target handle,
which I'm not going to do anything with,
but we do need to get that value.
So duplicate handle requires us.
To give a source process which is going,
to be our own process, a source handle which is that HTT,
attack Even though in this case, it points,
to a job object doesn't really matter.
And the target process,
is our own process again because in general this function can duplicate handle,
to a different process.
But I actually want to create another handle.
In the same process, and that handle value,
is going, to be returned using that HTT target,
um handle, address that I provided right here.
And then There's some access we can provide which
I'm not going to use right now, inheritance which we won't discuss at this point.
And In this case for the options,
just going to say duplicate same access which is simply
provide the same access to the new handle.
If this fails, it means I've run out of handles.
That can go ahead and Break out of this loop once again.
So we're starting with a single handle.
That's the one that's going to point, to the actual object initially,
but then we'll create more and more handles,
pointing, to the same object.
So if you go ahead, and change the main function,
to test two,
we can see What that looks like now if we build this
application open task manager here.
So what we expect to See in terms of memory,
we expect no big difference because a job object size,
is maybe be a few kilo, bytes So just a single object,
is Really nothing.
So let's do that and we can see that In terms of
memory doesn't seem to be changing, that much.
We're only going to uh have these memory wasted for the handles themselves.
Going back.
To the details here.
We can see the number of handles,
is indeed reaching its theoretical maximum and We we
consuming the page pull just like before.
Based on the handle entries themselves.
The fact, that the handle exists means 60 bytes has to be consumed to 60,
that handle, going to object explorer.
Here we can see Here in terms of handles we have now 60 million 60 handles,
two jobs, but the number of objects.
Is very small.
So we just created one additional job for this experiment.
Of course, the hand and peak objects still remain from the previous run.
Four when we used test one,
and not test two When we created jobs as many as we could.
And we actually were limited by,
by physical memory which were simply exhausting our physical memory.
So obviously here the big difference, is that We have a single object,
that has many many handles, to it, we can see that in cross explore or object,
explore itself.
So let's find here.
Our mac handles process here, here's mac handles,
and We should be seeing a mute tag, that has lots of handles.
So by default, because cross explore doesn't show named objects.
We have to change, that to show, an end handles,
and mappings, and then We need to find, that mu tax,
and the function,
is not going to be necessarily easy because we didn't write the
handle value at least one handle for that Tex.
But in fact, there, are So, many sorry, we're talking about jobs here there,
are So, many of those handles here, 60 million something.
So anyone will do if I double-click and you,
can see that Indeed, the number of handles.
Is crazy big for this kind of object.
In fact, the references here, is actually shown as a negative number.
In fact, it's a very big number rather than a negative number really?
So handles shown here.
That number of handles for that single job object,
and you can see the address, is the same.
So these are all handles, to the same exact object.
There's just so many of those there.
Error 60 million something handles, to that same job object,
and you, can see that there, are other handles,
in the this process, and That's why we couldn't get to exactly.
That limit in terms of handles, to jobs,
but still the majority of handles in this process.
Are about these single job, that we are pointing,
to So everything here we look at the properties,
remember, their properties, are for the object,
not for the handle.