Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] "corrupted size vs. prev_size" error when using libsumo in Java

Can you also attach the scenario files? A few cars approaching a single traffic light is insufficient for reproducing this problem on my end.

Am Do., 29. Dez. 2022 um 04:37 Uhr schrieb Nine, Harmon S via sumo-user <sumo-user@xxxxxxxxxxx>:
BTW, I'm using libsumo from sumo 1.15.0.
-- Harmon

From: sumo-user <sumo-user-bounces@xxxxxxxxxxx> on behalf of Nine, Harmon S via sumo-user <sumo-user@xxxxxxxxxxx>
Sent: Wednesday, December 28, 2022 9:36 PM
To: Nine, Harmon S via sumo-user <sumo-user@xxxxxxxxxxx>
Cc: Nine, Harmon S <harmon.s.nine@xxxxxxxxxxxxxx>
Subject: [sumo-user] "corrupted size vs. prev_size" error when using libsumo in Java

I'm using the Java interface for libsumo.  When using the
I'm getting a "corrupted size vs prev_size" error during runtime.

From the web, it appears this occurs when "memory chunk control structure fields in the adjacent following chunk are being overwritten due to out-of-bounds access by the code" (

The code that's incurring the error is below. It appears the error happens during garbage collection, I'm guessing when the
memory used by the data returned by "Vehicle.getNextTLS(vehicleId)" is reclaimed.

The error occurs on the explicit call to "System.gc()".  Without this call, the error occurs later, when garbage collection is implicitly called by the JVM.

How can this be fixed?

double oldModulus = 0;
int modulusPeriod = 90;
double currentTime = 0;
while(true) {
StringVector stringVector
= Vehicle.getIDList();
    for (String vehicleId : stringVector) {
        TraCINextTLSVector traCINextTLSVector = Vehicle.getNextTLS(vehicleId);
        if (traCINextTLSVector.size() > 0) {
            TraCINextTLSData traCINextTLSData = traCINextTLSVector.get(0);
            String tlsId = traCINextTLSData.getId();
            if (tlsId.equals("traffic-light-id")) {
                if (Vehicle.getSpeed(vehicleId) == 0.0) {

    double newModulus = currentTime - (int)(currentTime / modulusPeriod) * modulusPeriod;
    if (newModulus < oldModulus) {
        double average = stoppedVehicles/modulusPeriod;
        stoppedVehicles = 0;
        System.gc();  // WITH THIS CALL, THE "corrupted size vs. prev_size" ERROR OCCURS.
    oldModulus = newModulus;
    currentTime += 1;

-- Harmon
sumo-user mailing list
To unsubscribe from this list, visit

Back to the top